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]

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?
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.