Saturday, 28 May 2016

Object eligible for GC


1) When an object become no long accessed, for instance outside of its scope.
2) When an object reference variable is assigned a null, or re-assigned another object reference; so the object may become eligible for GC, for it might be not ref. any more.

Concept:
reference var. holding the reference value.
instance: it is instantiated in the heap memory by using new keyword, or specific case for the string using "hello world".

reference: more like the pointer in the C programming language; it points to a memory location of the instance.

Java passing by value:
When assigning an instance to a reference variable, its reference is copied to the reference variable.

When an instance has not been referred by any reference variable, then it is eligible to be released for saving resource. This is automatically by the garbage collector.

It is possible to explicitly declare a reference variable to be null, thus dissolving the binding with the instance. It is a way to release the instance, and become eligible to cleaned.

It is possible to explicitly force GC to do garbage collection, by using  System.gc() command. However, the impact is not guaranteed immediately.




No comments:

Can Jackson Deserialize Java Time ZonedDateTime

Yes, but must include JSR310. Thus ZonedDateTime can be deserialized directly from JSON response to POJO field. <dependency> <g...