Out of Memory Error

Hi,

I'm getting the error: java.lang.OutOfMemoryError: Java heap space

I expect my application to use a fair bit of memory, but increasing the heap size with -vmargs -Xmx256m doesn't make a difference to the point I get the error. It doesn't seem like Java is using the extra memory - or perhaps it's running out of a different type of memory? Does anyone have any ideas?

Thanks a lot!

[415 byte] By [syfaxa] at [2007-11-26 13:11:11]
# 1
Maybe it is exceeding 256M too.
aniseeda at 2007-7-7 17:26:21 > top of Java-index,Java Essentials,Java Programming...
# 2
Can not really give any pointers without know what you are up to.Are you keeping data after you no longer need it?
mlka at 2007-7-7 17:26:21 > top of Java-index,Java Essentials,Java Programming...
# 3
in case you have a memory leak, increasing the heap size would just effectively delay the out of memory error. So thats definitely not a fix in such a situation
kilyasa at 2007-7-7 17:26:21 > top of Java-index,Java Essentials,Java Programming...
# 4

I tried with 512mb too, but the error happens at exactly the same time; it doesn't seem to make a difference. For this reason, I don't think it'sa memory leak either.

Ok, so I'm making a chess playing computer. This involves using a recursive function to search a large tree of positions (typically 1-1.5 million nodes). Each call does generate instances that aren't needed later, but as far as I can tell there aren't any pointers to them, so they should be garbage collected.

The fact that increasing the heap size doesn't make a difference makes me think I might be running out of stack memory instead, perhaps?

syfaxa at 2007-7-7 17:26:21 > top of Java-index,Java Essentials,Java Programming...
# 5

You aren't getting a StackOverflowError, which would be the result of infinite recursion. You're running out of memory. Generally this is caused because "as far as I can tell there aren't any pointers to them" turns out to be untrue, and that could well be the case here. If you run your code inside a profiler you should get more insight into your memory usage.

DrClapa at 2007-7-7 17:26:21 > top of Java-index,Java Essentials,Java Programming...