Results 1 to 4 of 4
- 04-22-2009, 05:40 PM #1
Member
- Join Date
- Jun 2008
- Posts
- 85
- Rep Power
- 0
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.ArrayList.ensureCapacity(ArrayList.java: 169)
at java.util.ArrayList.add(ArrayList.java:351)
My program is looping through three files of capacity 91,80,199 KB.I am using eclipse.In the run configuration of my program i gave -Xms256M -Xmx512M in the vm arguments section and tried running the program i still get the same error.
my eclipse.ini has this information,should i also change this information?
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vmargs
-Xms40m
-Xmx256m
- 04-22-2009, 06:52 PM #2
Senior Member
- Join Date
- Nov 2008
- Posts
- 286
- Rep Power
- 5
No, don't change eclipse.ini. That sets the amount of memory etc for the Eclipse IDE itself, and that's not where the problem is occuring.
It sounds as though you're putting the settings in the right place. N.B. Just because the files are 91MB on disk doesn't mean that they'll be that size in whatever structure you're putting the contents to in Java. You seem to be adding the data to an arraylist of some kind. What actual objects are you putting in the array list. Have you properly considered the memory use and overhead of Java objects in your estimate of how much heap space you need to allocate?
On the page I mentioned, see the link to the Classmexer agent: this lets you query VM for the actual memory usage of an object. So you can load a small sample of your data into whatever format you're storing it in in memory, then query the usage of that sample and scale up accordingly.Last edited by neilcoffey; 04-22-2009 at 06:53 PM. Reason: added Classmexer link
Neil Coffey
Javamex - Java tutorials and performance info
- 04-22-2009, 07:57 PM #3
Member
- Join Date
- Jun 2008
- Posts
- 85
- Rep Power
- 0
Thanks for the reply i will go through the articles...i store the contents of the file as string in a hashmap.
- 04-22-2009, 08:25 PM #4
Senior Member
- Join Date
- Nov 2008
- Posts
- 286
- Rep Power
- 5
Hash maps are generally fairly memory-hungry. Remember that for each item you add, in addition to the fact that you're storing a key and a value, the hash map also has an internal entry object.
Remember too that Strings, in addition to their memory overhead for just being an object, use two bytes for every character. See my example CompactCharSequence class for a way to store strings one byte per character (provided they don't contain any "exotic" characters...).Neil Coffey
Javamex - Java tutorials and performance info
Similar Threads
-
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
By vasavi.singh in forum Advanced JavaReplies: 10Last Post: 05-11-2009, 11:56 AM -
Wanted help on "java.lang.OutOfMemoryError: Java heap space"
By itmani2020 in forum EclipseReplies: 16Last Post: 07-24-2008, 11:45 AM -
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
By Eku in forum NetBeansReplies: 14Last Post: 06-12-2008, 08:36 AM -
ERROR: Exception in thread "main" java.lang.NoSuchMethodError: main
By barney in forum New To JavaReplies: 1Last Post: 08-07-2007, 07:10 AM -
Error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
By romina in forum New To JavaReplies: 1Last Post: 07-25-2007, 10:55 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks