计算机科学与技术Java垃圾收集器中英文对照外文翻译文献.pdfVIP

  • 0
  • 0
  • 约1.09万字
  • 约 14页
  • 2026-02-27 发布于河南
  • 举报

计算机科学与技术Java垃圾收集器中英文对照外文翻译文献.pdf

中英文资料

中英文资料外文翻译文献

原文:

HowagarbagecollectorworksofJavaLanguage

Ifyoucomefromaprogramminglanguagewhereallocatingobjectson

theheapisexpensive,youmaynaturallyassumethatJava’sschemeof

allocatingeverything(exceptprimitives)ontheheapisalsoexpensive.

However,itturnsoutthatthegarbagecollectorcanhaveasignificant

oddatfirst—thatstoragereleaseaffectsstorageallocation—butit’sthe

waysomeJVMswork,anditmeansthatallocatingstorageforheap

otherlanguages.

Forexample,youcanthinkoftheC++heapasayardwhereeach

stakesoutitsownpieceofturfobject.Thisrealestatecanbecome

abandonedsometimelaterandmustbereused.InsomeJVMs,theJava

everytimeyouallocateanewobject.Thismeansthatobjectstorage

allocationisremarkablyrapid.The“heappointer”issimplymoved

it’snothinglikesearchingforstorage.)

Youmightobservethattheheapisn’tinfactaconveyorbelt,andif

youtreatitthatway,you’llstartpagingmemory—movingitonandoff

disk,sothatyoucanappeartohavemorememorythanyouactuallydo.

Pagingsignificantlyimpactsperformance.Eventually,afteryoucreate

collectorstepsin,andwhileitcollectsthegarbageitcompactsallthe

fault.Thegarbagecollectorrearrangesthingsandmakesitpossiblefor

thehigh-speed,infinite-free-heapmodeltobeusedwhileallocating

storage.

TounderstandgarbagecollectioninJava,it’shelpfullearnhow

garbage-collectionschemesworkinothersystems.Asimplebutslow

eachobjectcontainsareferencecounter,andeverytimeareferenceis

attachedtothatobject,thereferencecountisincreased.Everytimea

referencegoesoutofscopeorissettonull,thereferencecountis

1

decreased.Thus,managingreferencecountsisasmallbutconstant

overheadthathappensthroughoutthelifetimeofyourprogram.The

garbagecollectormovesthroughtheentirelistofobjects,andwhenit

Locatingsuchself-referentialgr

文档评论(0)

1亿VIP精品文档

相关文档