[go: up one dir, main page]

0% found this document useful (0 votes)
54 views74 pages

JVM Memory GC

This document discusses JVM memory management and garbage collection. It introduces key GC concepts like heap, generational GC, and object promotion. Different collector types like concurrent and parallel collectors are explained. The document dives into young generation GC mechanisms and minor collections. It also covers major collections and the Concurrent Mark Sweep collector. Profiling JVMs is presented as an important tool to understand GC behavior. The conclusion emphasizes understanding tools to improve programming skills.

Uploaded by

nagaraj_sairaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views74 pages

JVM Memory GC

This document discusses JVM memory management and garbage collection. It introduces key GC concepts like heap, generational GC, and object promotion. Different collector types like concurrent and parallel collectors are explained. The document dives into young generation GC mechanisms and minor collections. It also covers major collections and the Concurrent Mark Sweep collector. Profiling JVMs is presented as an important tool to understand GC behavior. The conclusion emphasizes understanding tools to improve programming skills.

Uploaded by

nagaraj_sairaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 74

JVMMemory

Management&
GarbageCollection

1.1
Goalsofthistalk

2.1
ItwillfocusonGCeducation

2.2
Youwilllearnaboutthe
lifecycleofanobject

2.3
IntroductiontoaJVM
profiler

2.4
Whydowecare?

3.1
beabletoreasonabout
code

3.2
responsiveandfaster
applications=moreprofit
$$$

3.3
weallwanttobemorelike
Batman

3.4
GCTerminology

4.1
1.Heap:memoryallocated
bytheJVMforallobjects

4.2
2.GenerationalGarbage
Collector

4.3
3.Collection:freeingupof
memory

4.4
4.ObjectPromotion:an
objectismovedfromone
partofheaptoanother

4.5
5.EdenSpace:newobjects
allocatedhere

4.7
6
6.SurvivorSpace:temp
storeforobjectsthathave
survivedayoungcollection

4.8
7.OldGeneration:longlived
objectslivehere

4.9
8.MinorCollection:
collectionintheyoung
generation,isfast

4 . 10
9.MajorCollection:
collectionintheold
generation,isslow

4 . 11
10.GCPause:timeduring
whichacollectionoccurs,
andtheapplicationcodeis
notrunning

4 . 12
11.StoptheWorldEvent:
applicationthreadsare
stoppeduntiltheoperation
completes

4 . 13
ConcurrencyVs
Parallelism

5.1
Concurrencyisthe
characteristicofasetof
tasks,wherebytheycanbe
executedindependentlyof
eachother.

5.2
Parallelismisawayof
executingconcurrenttasks,
onseparateprocessors.

5.3
DifferentCollector
Types

6.1
AConcurrentCollector
performsgarbagecollection
concurrentlywiththe
application'sownexecution

6.2
AParallelCollectoruses
multipleCPUstoperform
garbagecollection

6.3
SomeGClimits

7.1
ifwehadinfinitememory,
wewouldneverhaveto
collect,andGCwouldtake
0%oftheCPUtime.

7.2
ifwehadexactly1byteof
memory,GCwouldtake
100%oftheCPUtime.

7.3
GCCPUutilizationfollowsa
rough1/xcurvebetween
these2points

7.4
Commontoall
Younggeneration
GCmechanisms

8.1
identifyliveobjectsin
memoryheap

8.2
reclaimresourcesheldby
deadobjects

8.3
periodicallyrelocatelive
objectsviaobject
promotion

8.4
MinorCollection

9.1
occurswhentheedenspace
fillsup

9.2
optimizedassuminghigh
objectmortalityrate

9.3
survivorspacedividedinto
"to"space&"from"space

9.4
liveobjectsfromedenare
copiedtothesurvivor
space,edenisfreed.

9.5
survivingobjectsareaged
andmovedtoold
generation

9.6
workofminorcollection
proportionaltonumlive
objects

9.7
allminorcollectionsare
"StoptheWorld"events

9.8
MajorCollection

10 . 1
occurswhentheold
generationiscollected

10 . 2
triggeredbyminorGC

10 . 3
promotionfailurefrom
younggenerationtriggers
FullGC

10 . 4
FullGCcleansentireheap,is
veryexpensiveandshould
beavoided

10 . 5
oldgenerationcollector
triestopredictwhenit
needstocollecttoavoid
promotionfailure

10 . 6
TheConcurrentMark
Sweep(CMS)
Collector
11 . 1
runsintheoldgeneration
collectingtenuredobjects
nolongerreachable

11 . 2
runsconcurrentlywiththe
application

11 . 3
goalistokeepsufficient
freespaceinoldgensono
promotionfailureoccurs

11 . 4
CMSfollowsa
multistepprocess

12 . 1
1.InitialMark:findGCroots

12 . 2
2.ConcurrentMark:markall
reachableobjectsfromGC
roots

12 . 3
3.ConcurrentPre-clean:
nd object references that have updated
nd new objects that have been promoted
during the concurrent mark phase by
remarking

12 . 4
4.Re-mark:Captureobject
referencesthathavebeen
update

12 . 5
5.ConcurrentSweep:
updatethefree-listsby
reclaimingmemory

12 . 6
AdditionalCMS
Observations

13 . 1
CMSisnotacompacting
collector,mayresultinold
genfragmentation
Full GC may be triggered because of
fragmentation

13 . 2
CMSismostlyconcurrent
withtheapplication,which
means-
CPU time used for GC => less CPU time
available for application

13 . 3
CMSreducestheapp's
throughput,makesminor
collectionsmoreexpensive

13 . 4
Profiler

14 . 1
connecttoanyrunningJVM
process

14 . 2
canmeasureassumptions,
andprovethem
right/wrong

14 . 3
Demo!

15 . 1
Conclusion

16 . 1
garbagecollectionishard

16 . 2
understandyourtools,itwill
makeyouabetter
programmer

16 . 3
profileyourapplication,you
willoftenbesurprised

16 . 4
bemorelikeBatman!

16 . 5
Thanks!Questions?

17 . 1

You might also like