This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes System.gc() 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 » Beginning Java
Bookmark "System.gc()" Watch "System.gc()" New topic
Author

System.gc()

Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
Howdy. I've been doing some tweaks to an app hear at work. BTW, my app is served from 1 machine and not a product that we sell, so however it works on our app server is how it works. I also know all about System.gc() is just a request, not a guarantee. Anyhow, I noticed that if I put the call to System.gc in part of my code, when the app starts up I have about 10 megs more of memory freed up than with not doing it. My question is, am I suffereing too much of a performance hit to use GC at this point to only save 10 megs?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11153
    
  16

"too much" is a very vague term. too much for what? if you have 2k of free memory without doing it, and 10.002Meg of free memory with it, then i'd say probably not (although you probably have other issues).
how important is performance to this app? will somebody die if it takes it an extra millisecond? are there other places where performance is being effected?
I don't think there's really enough info in your post to give ANY kind of answer. you may want to look at some of the profiling tools available, and actually measure performance under different conditions.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: System.gc()
 
Similar Threads
Xalan memory problem - DOMSource vs. StreamSource
blob and query heap memory
Moving a big gob of java server stuff to a windows mobile contraption
Memory Leakage - Is "System.gc()" good to help solve this?
I think I have a memory leak: 33 megs of char arrays.. what to do?