This site requires JavaScript, please enable it in your browser!
Greenfoot back
BrownBoii333
BrownBoii333 wrote ...

2015/1/23

What is a heap space error

BrownBoii333 BrownBoii333

2015/1/23

#
I've gotten these before and most times they just go away after i switch computers. Is it just saying that it can't handle that amount of code or what? Also how can you fix something like this?
danpost danpost

2015/1/23

#
This is usually due more in what you have coded and not how much code there is. Without seeing the actual error stack trace, it would impossible to help in fixing it.
davmac davmac

2015/1/23

#
I've gotten these before and most times they just go away after i switch computers. Is it just saying that it can't handle that amount of code or what?
It's saying that the heap is exhausted. The heap is used to store objects and arrays. In Greenfoot, the most common cause of this is that you have a too-large image in your scenario's images folder. Another way of causing it is by having a "memory leak" in your program, where you continuously create more objects and do not reclaim old objects. In Java programs this isn't so common, since the "garbage collection" process normally will automatically re-claim heap space from unused objects, but it is still possible. Sometimes the problem occurs simply because you are creating too many objects.
Also how can you fix something like this?
As a general answer, either increase the size of the heap or create less objects.
You need to login to post a reply.