Skip to content

Tag: garbage-collection

Is the System.gc() call in a bad case?

From jdk/ at jdk8-b120. Does this help with exception recovery? Answer When an object allocation fails with an OutOfMemoryError, the garbage collector did already try its best to reclaim memory of unused objects or expanding the heap. So calling System.gc() after catching OutOfMemoryError would be pointless. A special case is the situation when the garbage collector repeatedly did reclaim a

How to assert some Java method is garbage free?

I have a piece of code that (currently) use Java 8’s Optional and Stream. And we started having GC overhead issues since this code was deployed to production. See the gist of the code below (getters, constructors and overloads removed for clarity): While it could be unrelated, I’d like to make this code garbage free, especially since it’s a code

Where is the “age threshold” for the referenced object stored in Garbage Collection process stored?

I am trying to understand how GC works and have been reading Garbage Collection Process, point #6 says, “After a minor GC, when aged objects reach a certain age threshold (8 in this example) they are promoted from young generation to old generation.” I am trying to understand where the “age threshold” for the referenced object stored? Answer This