国产精品婷婷久久久久久,国产精品美女久久久浪潮av,草草国产,人妻精品久久无码专区精东影业

java垃圾收集器的工作方式 -------畢業(yè)設(shè)計(jì)外文文獻(xiàn)翻譯.doc

約10頁DOC格式手機(jī)打開展開

java垃圾收集器的工作方式 -------畢業(yè)設(shè)計(jì)外文文獻(xiàn)翻譯,if you come from a programming language where allocating objects on the heap is expensive, you may naturally assume that java’s scheme of allocating everything ...
編號(hào):10-269048大小:48.00K
分類: 論文>外文翻譯

內(nèi)容介紹

此文檔由會(huì)員 wanli1988go 發(fā)布

If you come from a programming language where allocating objects on the heap is expensive, you may naturally assume that Java’s scheme of allocating everything (except primitives) on the heap is also expensive. However, it turns out that the garbage collector can have a significant impact on increasing the speed of object creation. This might sound a bit odd at first—that storage release affects storage allocation—but it’s the way some JVMs work, and it means that allocating storage for heap objects in Java can be nearly as fast as creating storage on the stack in other languages.
For example, you can think of the C++ heap as a yard where each stakes out its own piece of turf object. This real estate can become abandoned sometime later and must be reused. In some JVMs, the Java heap is quite different; it’s more like a conveyor belt that moves forward every time you allocate a new object. This means that object storage allocation is remarkably rapid. The “heap pointer” is simply moved forward into virgin territory, so it’s effectively the same as C++’s stack allocation. (Of course, there’s a little extra overhead for bookkeeping, but it’s nothing like searching for storage.)
如果你學(xué)下過一種因?yàn)樵诙牙锓峙鋵?duì)象所以開銷過大的編程語言,很自然你可能會(huì)假定 Java 在堆里為每一樣?xùn)|西(除了 primitives)分配內(nèi)存資源的機(jī)制開銷也會(huì)很大。不過,事實(shí)上垃圾收集器能夠深刻影響對(duì)象的加速創(chuàng)建。 一開始聽起來有些奇怪——存貯空間的釋放會(huì)影響存貯空間的分配,但是這的確是一些 JVMs 的工作方式,并且這意味著 Java 為堆對(duì)象分配存貯空間幾乎和別的語言里為棧分配存貯空間一樣地快。
舉個(gè)例子,你可以認(rèn)為 C++的堆就如同一個(gè)堆放的工場(chǎng),在這個(gè)工場(chǎng)里,每一個(gè)對(duì)象都立有的地皮占有權(quán)不久會(huì)被廢除無效,并且這塊地皮必須重新加以利用。在Java 的 JVM 里,堆的工作方式完全不同;每次為一個(gè)新的對(duì)象分配存貯空間的時(shí)候,它就更像是一個(gè)不斷向前移動(dòng)的傳送帶。 這就意味著對(duì)象存貯空間的分配速度明顯加快。 在這個(gè)過程中,“堆指針”簡(jiǎn)單地向還沒被占用的空間領(lǐng)域移動(dòng),所以非常像 C++里棧的分配方式。(當(dāng)然,記錄工作會(huì)有一點(diǎn)額外的開銷,但是完全不同于 C++里那種在堆放工場(chǎng)里為尋找沒被利用的存貯空間而付出的開銷。)