Skip to main content

Posts

Showing posts from June, 2015

Refrences Type Java

To understand Garbage collection mechanism we must know about the various reference types for object because on that basis the GC reclaim the memory from the object There are following 4 kinds of reference types in Java:     Strong references.     Weak references.     Soft references.     Phantom references. Strong reference: It is most simple as we use it in day to day programming. if not differently specified then an object is a strong Reference Object Ex String language="English"; A new string object will be created and  a strong reference to it would be stored in the variable 'language'; If any object has a strong reference or it is reachable by any chain of strong reference then JVM will not garbage collect it to avoid any situation where it destroy the object which is currently being worked upon. Weak reference: These are created using WeakReference class which is present in the java.lang.ref . Weak...

Garbage Collector

Garbage Collector : finalize  In C/C++ or all the languages before java we used to manually free the unused memory by deleting the objects/reference created so that system can use that memory for another objects or for other purpose. In java the objects which system can identify as "no longer in use" can be marked as garbage and later recycled. It is also called memory recycling. Most of the object are not used after sometime only few has references further in the program. So java identify those objects which are no longer in use and recycles the memory. So it helps the programmer to relieve the burden of memory management and hence increase the productivity. Garbage collection process mainly handles memory management process, it does not take care about network connection or database connection or any user windows. Those has to be manually managed by programmer. If any of the object is associated with other memory space and before the object is garbage collected an...