Flat 10% off on the purchase of any two apps or more. Use coupon code - FESTIVAL10
Native Shopify Mobile App with 20 new features
Kickstart your hyperlocal marketplace in Corona pandemic with a starter guide
Android App Development
iOS App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 22.214.171.124 release ready!
Owner and Founder. Opencart
Garbage collection in Java is the automatic process for memory management.It is the way to remove/destroy unused objects.
In C language allocation and deallocation of memory is the manual process. But in java, deallocating memory process is handled automatically by the garbage collector.
Basically, Automatic garbage collection is the process of looking at heap memory, identifying which objects are in use and which are not, and deleting the unused objects.
To determine which objects are no longer in use, the JVM intermittently use Mark and Sweep algorithm.
Basically, it consists of two steps.
In this step, the Garbage collector identifies the used and unused objects and mark the used object.
Step 1: SweepIn this step, all unused objects will be deleted. All of the heap memory which was used by unused objects is free now and available for further use.
Automatic deallocation makes java memory efficient.Programmers don’t have to worry about memory as It is automatically done by the garbage collector.
There are several ways to make an object eligible for garbage collection.
2. Assigning a reference to another:
For example :
3. Anonymous object:
Before destroying an object, Garbage Collector calls finalize() method on the object to perform cleanup activities. Once finalize() method completes, Garbage Collector destroys that object.
This method is present in the Object class.
Once an object is eligible for garbage collection, it may not destroy immediately by GC.It will be garbage collected once GC will be run and we can’t predict when GC will be run.Although we don’t know when will GC run, we can request JVM to run GC by using System.gc() method.
Hope this post will give an idea about Garbage Collection in java
Thank you !!
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
When I think in getting solutions for my Ecommerce Platform, I think of Webkul. They have been such a blessing in our business. We have spent thousands of dollars in support and modules from them. We love their support team. They work very closely with us, and they always go the extra mile when we need help.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.