Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

garbage collection for memory recovery

Status
Not open for further replies.

vulcand4

Programmer
Jul 29, 2003
76
US
I have a Java Servlet application running on my web server. It seems to be chewing up memory faster than the garbage collector can give it back.

Would running the System.gc() method periodically be a good solution, or is there a better solution out there?

Thanks for any help you can provide.
 
have you revisited the design side? One advice that I can give is not to design your application around thread and gc. The behaviors of these two items are unpredictable. For instance, you cannot control gc cleaning up schedule.

Therefore, the solution of calling system.gc is not feasible. I understand that you want the object to be cleaned up, but still your request is at the mercy of the gc - an improbable that you might want to avoid. There might be a case where because of timing issue, the gc doesn't clean up quick enough that the next logic has to face the consequences.

One thing you can do is to set the object to null explicitly. Also, I would suggest you revisit the codes and figure out which portion of the codes is chewing up the memory.

~za~
You can't bring back a dead thread!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top