de reference Objects if possible

HI

I have an application which runs a simulation model (of some scientific parameters over a period of time) and produces some nice output graphs (from an array of processed output data)

However if the model was to be run again, the same (but new Objects) are created and thus each simulation adds around 10Megs of memory.

So I have a memory leak, and I guess there are two ways to fix this:

1.Use the Same Object again (just reset a few variables and arrays)

2.De Reference an Object (delete it and free memory)

I would prefer to do the latter, as creating the Object again is probably easier and quicker than wiping a large array of data etc,etc

I know Java has its own Garbage collector but obliviously for some reason I am keeping a reference to the object due to the nature of the code, design etc.

I have tried myObject = null;

But that doesnt seem to work.

Any suggestions? Code examples?

Cheers

[978 byte] By [Tiblea] at [2007-11-27 11:40:46]
# 1

myObject = null; does work. However, when dealing with graphics sometimes there are resources which must be explicitly released. I would have to see how you are doing your code to know for sure. Be sure to read the API/Javadoc on the graphics classes you are using.

_dnoyeBa at 2007-7-29 17:33:52 > top of Java-index,Core,Core APIs...
# 2

Thats sounds about right I have been using the jfreechart API to do the graphics

http://www.jfree.org/jfreechart/

I guess i will have a look around in the javadocs there to see if there is anything specific.

You have to pay for the developers manual, which I should be getting soon, which is also the most likely it will be documented

might try their forums too

Thanks for your help, anyone with comments on jfreechart please post

Tible

Tiblea at 2007-7-29 17:33:52 > top of Java-index,Core,Core APIs...