Memory Leak: Deleting the Exception/Throwable Objects which are thrown from elsewhere

David Daney ddaney@avtrex.com
Mon Feb 4 17:13:00 GMT 2008


abhi123 wrote:
> This is my class
> class ExceptionClass
> {
> 	public void throwException() throws Exception
> 	{
> 		throw new Exception();
> 	}
> }
> 
> And I have compiled its .class, .o and .h files
> Now in my main I have included it <gcj/cni.h> and <ExceptionClass.h> also
>     JvCreateJavaVM(NULL);
>     JvAttachCurrentThread(NULL,NULL); in the begining and
> JvDetachCurrentThread(); in the end
> 
> Problem here is in I have a while loop which runs indefinitely and goes on
> creating 
> ExceptionClass objects and each invokes above throwException method. And
> everytime that method gets invoked a new Exception object is created which
> leads to memory leak because I am not able to delete it from main (or could
> say deleting doesn't help). How can I stabilize the memory utilization.

The libgcj runtime has a garbage collector.  There should be no problem.

If you can create a stand-alone testcase that shows a real problem, we 
will try to fix it.

David Daney



More information about the Java mailing list