ran simple code try see how garbage collectors function.
string = null; while ( true ) { = new string(" no... "); }
i using parallelgc. printed gc results , here first (minor) gcs.
[gc [psyounggen: 16448k->1616k(19136k)] 16448k->1624k(62848k), 0.0022134 secs] [times: user=0.00 sys=0.00, real=0.00 secs]
younggen came down 14880k
fullheap came down 14872k
does mean 8k has moved tenure generation? understanding gc might have been called instanced of class 'a' must have been marked alive , moved tenure generation. understanding correct? also, "floating garbage"? overtime tenure generation filled , fullgc required, take awhile.
also, in particular case, shoudln't entire minor collection collected , ideally nothing goes tenure generation? these short lived objects.
you've got 1 instance of string alive when gc in progress (the strong reference inside while loop) 1 one survives hence 8k.
in case wouldn't call string ref floating garbage. floating garbage when object wasn't ready gced when gc checked it, ready time gc finished. example of be.
thread1: person p = new person("sammy") thread2: gc runs , sees person instance reachable through p. thread1: p = null; // person instance unreachable. thread2: gc finishes. person instance have been collected reachable @ time collector checked it.
Comments
Post a Comment