![]() Just before destroying an object, Garbage Collector calls finalize() method on the object to perform cleanup activities.The call System.gc() is effectively equivalent to the call : Runtime.getRuntime().gc().There is no guarantee that any of the above two methods will run Garbage Collector.Hence by using its gc() method, we can request JVM to run Garbage Collector. Using Runtime.getRuntime().gc() method: Runtime class allows the application to interface with the JVM in which the application is running.Using System.gc() method: System class contain static method gc() for requesting JVM to run Garbage Collector.We can also request JVM to run Garbage Collector.But when JVM runs Garbage Collector, we can not expect. Whenever JVM runs the Garbage Collector program, then only the object will be destroyed. Once we make an object eligible for garbage collection, it may not destroy immediately by the garbage collector.Ways for requesting JVM to run Garbage Collector ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |