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

2017/3/26

java.lang.OutOfMemoryError: Java heap space

Dylex Dylex

2017/3/26

#
I have a fairly large and complicated game, not sure what this issue is but i'm getting a problem with one of my classes, most specifically this line of code here: image.scale(image.getWidth() * pixToHeightRatio, image.getHeight() * pixToHeightRatio); It all comes from this class here: public Background(String startImage, int pixToHeightRatio, int startWorldWidth, int startWorldHeight) { setImage(startImage); GreenfootImage image = getImage(); image.scale(image.getWidth() * pixToHeightRatio, image.getHeight() * pixToHeightRatio); setImage(image); } This issue only happens occasionally when i hit 'reset'.
danpost danpost

2017/3/26

#
An OutOfMemroyError is not usually caused by any one thing -- but the whole of it. You apparently have many large images which takes up a lot of memory space. See what you can do about maintaining images in String form until needed -- and reducing the scale would be a big help. Having actors from the same classes share their images (or image sets) would also help.
Dylex Dylex

2017/3/26

#
danpost wrote...
An OutOfMemroyError is not usually caused by any one thing -- but the whole of it. You apparently have many large images which takes up a lot of memory space. See what you can do about maintaining images in String form until needed -- and reducing the scale would be a big help. Having actors from the same classes share their images (or image sets) would also help.
I'll have to have a look around and see where i can

optimise

memory usage. But the issue only arrises when repeated switching worlds or resetting the game world, it seems to be me like the memory i am using is not be freed up once i am no longer using it, what's the deal with that?
You need to login to post a reply.