File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Why does my actionclass accumulate memory? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Why does my actionclass accumulate memory?" Watch "Why does my actionclass accumulate memory?" New topic

Why does my actionclass accumulate memory?

Mattias Andersson

Joined: Nov 17, 2010
Posts: 20
I have an actionclass which is called by ajax on the web page.
I create only an object of Testclass.
Looking in a memory profiler I can see that for each ajax request there is a new Testclass on the heap.
Even if thisClass in nulled it is still there on the heap.
And next time this action executes there are 2 Testclass on the heap etc...

Is there anyone who can tell me whats wrong?
I have been struggling with this problem a few days now and are starting to get desperate.

It's better to be approximately right than exactly wrong.
Joe Ess

Joined: Oct 29, 2001
Posts: 9191

Garbage collection is not instantaneous. If you have a large heap, you may accumulate many instances before they are swept up.
Your profiler may have a way to trigger garbage collection. Try that and see what happens.

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: Why does my actionclass accumulate memory?
It's not a secret anymore!