answersLogoWhite

0

A Garbage Collector in Java is a Java program that runs automatically every few seconds to check if there are any objects in the JVM memory that is not being used/referenced by the programs that are being executed.

If so, such objects would be removed from the memory, making the free memory available for the other objects to use.

This is very good for us because, we need not write specific programs to release unused objects to ensure that our application has enough memory to keep running.

If the garbage collector is not there, then we would have manually write the code to ensure that our app keeps running. If we don't have the garbage collector, then we would be very frequently getting Out of Memory error in our application.

User Avatar

Wiki User

16y ago

What else can I help you with?

Continue Learning about Engineering

Memorymically and and not reclaming it when it is no longer it is needed in java there is no such problem as there is as garbage collector what is it?

I guess you want to talk about the garbage collector feature that Java has. The garbage collector is an automated program that the Java virtual machine would run once in a while. This program would clean up unused memory to ensure that there is enough memory available for the programs. you can invoke the garbage collector by calling the system.gc() method but this does not guarantee an invocation of the garbage collector. the JVM may or may not call the GC when we invoke it...


How do you write a Program on garbage collector in java?

Garbage collection is an operation that happens automatically in Java. We cannot write programs to perform them. All we can do is call the system's implementation of the Garbage collector and hope that it would execute. "Runtime.gc();" Place the above piece of code in your code, if you want to invoke the garbage collector. Invoking the runtime's implementation of the gc does not guarantee the execution of the garbage collector. It may or may not run. The JVM decides on that.


What is memory leak problemin java?

Memory leaks do not occur in Java as the garbage collector clears the memory which has no references.


What is the difference between garbage collector and finalization?

When all references to an object is Java are gone, the garbage collector will come along and free up the memory used by that object.Every Java object has a method named finalize, which is called by the garbage collector when the memory for that object is being deallocated. "Finalization" is just a name given to the act of calling the finalize method during garbage collection.


What statement instructs a program to run the garbage collector?

In the case of the Java language, you can use the command:System.gc();Note that this should be interpreted as a suggestion to run the garbage collector; there is no guarantee that it will run immediately.

Related Questions

How garbage collector works on anonymous class in java?

about the garbage collector it is in java and it is mainly responsible for dynamic memory manegement


Garbagecolllecter in java?

Yes, Java programming language has a Garbage collector for unused memory. and the best part about it is that it does it automatically. The Garbage Collector is built into the Java Virtual Machine, and will do automatic garbage collection for you. If you chose to compile your Java code down to native code (via a Java->native code compiler), then NO garbage collection is done for you.


Memorymically and and not reclaming it when it is no longer it is needed in java there is no such problem as there is as garbage collector what is it?

I guess you want to talk about the garbage collector feature that Java has. The garbage collector is an automated program that the Java virtual machine would run once in a while. This program would clean up unused memory to ensure that there is enough memory available for the programs. you can invoke the garbage collector by calling the system.gc() method but this does not guarantee an invocation of the garbage collector. the JVM may or may not call the GC when we invoke it...


How do you write a Program on garbage collector in java?

Garbage collection is an operation that happens automatically in Java. We cannot write programs to perform them. All we can do is call the system's implementation of the Garbage collector and hope that it would execute. "Runtime.gc();" Place the above piece of code in your code, if you want to invoke the garbage collector. Invoking the runtime's implementation of the gc does not guarantee the execution of the garbage collector. It may or may not run. The JVM decides on that.


What is memory leak problemin java?

Memory leaks do not occur in Java as the garbage collector clears the memory which has no references.


What is the difference between garbage collector and finalization?

When all references to an object is Java are gone, the garbage collector will come along and free up the memory used by that object.Every Java object has a method named finalize, which is called by the garbage collector when the memory for that object is being deallocated. "Finalization" is just a name given to the act of calling the finalize method during garbage collection.


What statement instructs a program to run the garbage collector?

In the case of the Java language, you can use the command:System.gc();Note that this should be interpreted as a suggestion to run the garbage collector; there is no guarantee that it will run immediately.


Why are you used new operator in main method in java?

new is used for memory allocation in java which on later automatically deallocated by garbage collector.


What is a garbage collector called?

In Java it is called by the same name "Garbage Collector" The purpose of the garbage collector to free up unused heap space so that it can be utilized by the other programs. All unused objects are cleared using the GC to create space for other applications/programs.


What is systemgc in java?

A call to System.gc() will tell Java that you want it to run the garbage collector. Use of this method is discouraged, especially since Java can simply choose to ignore the call if it's not necessary.


What is the garbage collection in java?

The garbage collector is a process that will search for unreachable objects - objects which can't be reached from the main program - and destroy them, thus reclaiming the space they use.


What is GC in java?

GC stands for garbage collector - this is the mechanism which cleans up unused object references. The GC is why memory management in Java is almost non-existent.