![]() As a result the program utilizes more and more memory until it finally crashes because there is no more memory left.Īs a smart QA, you will not want these issues to happen in your application. Basically, it is nothing but a bug in program that prevents it from freeing up memory that is no longer needed. Java virtual machine throws OutOfMemoryError or. If there is no memory space present for creating new objects in Heap. This process is called garbage collection. Unused objects are discarded and memory is reclaimed and reused again. During the usage of an application JVM periodically verifies which objects in memory are still being used and which are not. It’s upto Java Virtual Machine (JVM) to decide when to automatically run the Garbage collector. In a Java based application, Garbage collector reclaims objects that are not used. Garbage collector collects those objects that are not GC roots and are not accessible by references from GC roots. Once the memory is freed it can be reused for future allocation. When an application needs to use a certain amount of memory temporarily it can allocate the memory from the heap and when this is no longer needed it can be freed up. It is basically an area of memory used for dynamic memory allocation. Ok, now what is Heap? A heap is a form of data structure that is similar to a tree. Other objects on the heap reachable from the GC roots are considered to be live objects, and ineligible for garbage collection, the objects that are unreachable can be marked for reclamation. ![]() GC Roots therefore are always ineligible for collection. ![]() If an object is always reachable, then it is not eligible for garbage collection. Garbage Collection (GC) Roots are the objects that are always reachable. If the cache grows increasingly to cause problems, this may be a programming or design error, but is not a memory leak as the information is not used much. Applications may store some amounts of information in memory in form of cache. A memory leak is the result of a programming bug, so it is very important to test it during development phase.Īlso, a constantly increasing memory usage is not necessarily evidence of a memory leak. For a program that is frequently opened or that runs continuously, even a very small memory leak can eventually cause the program to terminate. As a result, the available memory for that application drains out completely and the programs can no longer function. In simple language a memory leak is loss of available memory when a program fails to return memory that it has obtained for temporary use.
0 Comments
Leave a Reply. |