File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes OutOfMemoryErrors and the native heap Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "OutOfMemoryErrors and the native heap" Watch "OutOfMemoryErrors and the native heap" New topic

OutOfMemoryErrors and the native heap

Mike Noel
Ranch Hand

Joined: Dec 15, 2005
Posts: 108
I've got an application that was started with mx512m. My understanding is that this limits the JVM heap to 512MB of space. While watching the actual java process (using top) I am seeing the memory usage for the process go up to over 1GB of memory. Once the memory gets this high I start seeing java.lang.OutOfMemory errors.

One of the packages I'm using seems to be using the File.deleteOnExit() method. A bug on Sun's site indicates that this method causes native heap memory leaks. I can understand that that would cause my process memory to go up but would it cause OutOfMemoryErrors?.

I thought that the OutOfMemoryError meant that I didn't have anymore JVM heap space left (limited to 512mb in my case). Is it possible that I'm seeing the OutOfMemoryError due to the size of the native heap?



Mike Noel
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3753

Have you monitored garbage collection to see how frequent it is being performed? OutOfMemoryErrors can be caused any time garbage collection (assuming it ran) fails to re-allocate enough memory to continue.

I'd run your application through a 3rd party profiling tool and monitor memory allocation and use. The memory leak could be coming from anywhere.

[OCA 8 Book] [Blog]
Mike Noel
Ranch Hand

Joined: Dec 15, 2005
Posts: 108
It looks like that's what I'm going to have to do. My problems seem to revolve around the apache commons FileUpload package so I may have to dig into that code too.

I agree. Here's the link:
subject: OutOfMemoryErrors and the native heap
It's not a secret anymore!