cancel
Showing results for 
Search instead for 
Did you mean: 

Garbage Collector

Former Member
0 Kudos

when and how the garbage collector delete the instance variables LIKE int i,float f;

class{

int i;

float f;

}

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Valery,

What I said was it normally runs as a low priority thread but it runs as a high priority one when available memory goes dangerously low(See the answer above).

Regards,

Pooja.

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi,

The <b>Java garbage collector</b> runs as a low-priority thread, so it does most of its work when nothing else is going on, such as during idle time while waiting for user input.

The only time the garbage collector must run while something high-priority is going on (i.e., the only time it will actually slow down the system) is when available memory has become dangerously low. This doesn't happen very often because the low-priority thread cleans things up in the background.

This is actually an automatic process.

Regards,

Pooja.

Former Member
0 Kudos

Pooja,

Small correction -- the other condition when it is invoked is when JVM runs out of available memory.

VS

Former Member
0 Kudos

Hi

If you r using System.gc in your program explicitely it free all the instances other wise of you are not using one particular variable for longer time it would be automatically garbage collected.

I think it help you to solve your problem.

Thanks

Mrutyunjaya Tripathy

Former Member
0 Kudos

Karsten and Mrutyunjaya,

you should not rely on "manually" calling any of the .gc() methods! E.g. in Netweaver the <b>.gc()</b> disabled with +DisableExplicitGC JVM option.

And besides that, <b>.gc()</b> gives the JVM just a "suggestion" for a GC, there's no guarantee that such will happen.

Former Member
0 Kudos

Hi Guruvulu Bojja,

Garbage Collector: A very good Memory Manager.

You can clear your queries by verifying these links...

1. About Garbage Collector.

http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)

2. The Mysteries of Distributed Garbage Collection

http://www.thinktecture.com/Resources/RemotingFAQ/Lifetime.html

3. Java theory and practice: A brief history of garbage collection

http://www-128.ibm.com/developerworks/java/library/j-jtp10283/

4. Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework

Part-I.

http://msdn.microsoft.com/msdnmag/issues/1100/gci/

Hope it helps.

5. Part-II

http://msdn.microsoft.com/msdnmag/issues/1200/GCI2/

6. Java's garbage-collected heap

http://www.javaworld.com/javaworld/jw-08-1996/jw-08-gc.html(Click on next link to explore more)

7. Reference Objects and Garbage Collection

http://java.sun.com/developer/technicalArticles/ALT/RefObj/

8. GC-FAQ's

http://java.sun.com/docs/hotspot/gc1.4.2/faq.html

Hope it helps.

Regards,

Maheswaran.B

Message was edited by: Maheswaran B

Former Member
0 Kudos

Hi Guruvulu,

you can call the garbage collector by hand:

Use

Runtime.getRuntime().gc();

Before and after calling the gc you can check the free memory of your machine:

Runtime.getRuntime().freeMemory();

So you can check if the gc has done something.

Hope it helps,

Kasrten

Former Member
0 Kudos

when instance itself is deleted.

actually, they (any primitives) are part of instance and resides in memory allocated per instance, JVM / GC does not manage them separately

VS

Former Member
0 Kudos

Hi Guruvulu,

A key feature of Java is its garbage-collected heap, which takes care of freeing dynamically allocated memory that is no longer referenced. Because the heap is garbage-collected, Java programmers don't have to explicitly free allocated memory.

TO have a clear understanding of garbage collection,refer the following link:

http://www.javaworld.com/javaworld/jw-08-1996/jw-08-gc.html

Regards,

Anuradha.B