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

2012/8/26

Is there a way to instrict greenfoot to reserve more RAM?

1
2
Gevater_Tod4711 Gevater_Tod4711

2012/8/26

#
Hi all, my problem is that my scenario is very big and sometimes there is not enough RAM for my scenario, although I have much more than eneugh. And then I get hundrets of OutOfMemoryErrors (most times while compiling). So, is there a way greenfoot reserves more RAM for my scenario? thanks for help.
SPower SPower

2012/8/26

#
Maybe it is more useful to don't use much memory, are you doing something like creating many GreenfootImages or something like that?
Gevater_Tod4711 Gevater_Tod4711

2012/8/26

#
yes very many Images. Like I say: a very big game
SPower SPower

2012/8/26

#
Can't you just reuse the images? Like this:
// instead of something like this:
setImage(new GreenfootImage(100,100);
// do this:
getImage().clear();
getImage().scale(100,100);
that's faster, and uses less memory.
Gevater_Tod4711 Gevater_Tod4711

2012/8/26

#
You mean I shouldn't use setImage but repaint my images? Yes, I could do so. But I think that will not be enough.
SPower SPower

2012/8/26

#
I mean that clearing and scaling an image is more effecient than creating a new one.
Gevater_Tod4711 Gevater_Tod4711

2012/8/26

#
Yes I know what you mean but I think my problem aren't just the images. The hint with repaint is good I think, but I don't think it'll be enough.
SPower SPower

2012/8/26

#
I understand. What other things do you do that use up a lot of memory?
Gevater_Tod4711 Gevater_Tod4711

2012/8/26

#
I use images, soundfiles, and many many classes and objects. I don't know what of that takes the most memory?
SPower SPower

2012/8/26

#
Images and sounds are the problem I think. You could try not to load all the sounds of the game, but just load a few from disc.
Gevater_Tod4711 Gevater_Tod4711

2012/8/26

#
Another Question (to your hint with the images): If I use the methods like you tould me: If I overwrite the Image with another image (after cleaning it) and this Image is another size, must I change the size of the image I want to overwrite or will greenfoot do this for me?
SPower SPower

2012/8/26

#
You have to do it yourself
Gevater_Tod4711 Gevater_Tod4711

2012/8/26

#
ok thank you. That will help (I hope).
gusbus123 gusbus123

2012/8/29

#
btw use .mp3 files for ur sound cause it takes less space.
Builderboy2005 Builderboy2005

2012/8/29

#
Note that if you use SetImage("imageName") it will create a new GreenfootImage every time you run that. It is better to create a GreenfootImage once and use that image instead of creating a new one. I'm not sure if this is what you are doing, but it is worth mentioning :P
There are more replies on the next page.
1
2