File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Garbage Collector decreases available memory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Garbage Collector decreases available memory" Watch "Garbage Collector decreases available memory" New topic
Author

Garbage Collector decreases available memory

S Lei
Greenhorn

Joined: Feb 20, 2010
Posts: 7
Hello,
Nearly every time I used the gc() method in the Runtime object, I was noticing, that it actually seemed to consume a few megabytes of my available memory. I used the method directly after heavy-duty image operations where I disposed all objects and nulled the database. I don't know why this happens, any ideas?

Thanks =)
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

That's very hard to answer without knowing in detail what your program does.

It is almost always not necessary to call the gc() method. The garbage collector in the JVM is a sophisticated piece of software, and usually it knows better than you how and when to do garbage collection. You should never call gc() just because you have some vague feeling that it might be a good idea - trying to "help" the garbage collector might even be counter-productive, as you've discovered with your program.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
S Lei
Greenhorn

Joined: Feb 20, 2010
Posts: 7
Mh. Yes, I think that would be the solution, to just let it do it's job . I only thought, that it might be a good idea sind I heard a speech about it long ago, in which the garbage collection jsut seemed to cleanup in regular time-periods.

Kind Regards,
Simon Leischnig
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Garbage Collector decreases available memory
 
Similar Threads
poi and protected excel book
Dynamically determining the amount of available memory
Memory of System
Memory Control
Desktop vs HTML5(Browser) games