Meaningless Drivel is fun!*
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
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: 11320
    
  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
 
 
subject: System.gc()