Java heap space out of memory error [message #334271] |
Fri, 30 January 2009 02:46  |
Eclipse User |
|
|
|
Hi All,
I have a plugin handling data for a specific type of files. The plugin
loads data from a file into a data module, then creates a multipage editor
to display and edit the data module, and finally writes data back to the
file.
The data module is created thru a factory class's getInstance(File
editingFile) static method, which enables the plugin to edit mulitiple
files at the same time. Inside the factory class, a static HashMap is used
to keep track of each java.io.File object and its corresponding data
module.
The plugin works just fine until when tests it with a fairly big file:
open the big file and then close it immediately for several times, a java
heap space out of memory error occurs.
With Java VisualVM, I found the plugin keeps about 8M heap memory
unreleased after being closed. I tried every way to solve it but could
not: it seems to me that all the widgets have been disposed, the data
module has been removed from the factory class.
Any ideas? Or is there any tool can help me to find who stays in the heap
not cleaned up?
Thanks in advance!
Sharon
--
http://www.eclaxy.com
|
|
|
|
Re: Java heap space out of memory error [message #334289 is a reply to message #334271] |
Fri, 30 January 2009 16:46  |
Eclipse User |
|
|
|
"Sharon" <sharon.floyd@eclaxy.com> wrote in message
news:d9fd030cf8e55a74e7d14bbdca55cba5$1@www.eclipse.org...
> The data module is created thru a factory class's getInstance(File
> editingFile) static method, which enables the plugin to edit mulitiple
> files at the same time. Inside the factory class, a static HashMap is used
> to keep track of each java.io.File object and its corresponding data
> module.
Just to check: you are removing the entry from that map, when the file is
closed, right?
I've found that whenever using these sort of static maps that track dynamic
data it is very important to think about the references. Sometimes it helps
to have it be a Map<File, WeakReference<Thing>> rather than just a Map<File,
Thing>, so that there isn't a circular reference that prevents the Thing
from ever actually being released.
|
|
|
Powered by
FUDForum. Page generated in 0.03544 seconds