Hi all,
How to avoid memory leakage problrm in Java,
according to our design , we are creating lots of objects for every request, so we are getting memory out exception..
Give me some solutions
Thanks in advance
Sankarguru.T
Printable View
Hi all,
How to avoid memory leakage problrm in Java,
according to our design , we are creating lots of objects for every request, so we are getting memory out exception..
Give me some solutions
Thanks in advance
Sankarguru.T
By making sure you don't hang to references to the instances outside of the necessary scope. Nothing else.
Another solution - you can give more memory to the JVM instance.
the cmd line will look like: java -Xmx1300m -cp ....
As masijade said, make sure any references are removed when the objects go out of scope or are not required any more - particularly references in static lists and references held in long-lived objects, e.g. as listeners/observers.
You could try using the Flyweight Design Pattern to minimize memory use by sharing as much as possible between objects.