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

2018/4/5

Greenfoot out of memory error

Acituanbus Acituanbus

2018/4/5

#
Hey, I almost finished my game, and everything works fine if I load the final screen on its own, but if I play through the game, instead of loading the "credits" image (which is 1028 x 7800 pixel), it says it ran out of memory.. Is there a way to fix that? This is the exact error:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
java.lang.OutOfMemoryError: Java heap space
    at java.awt.image.DataBufferByte.<init>(DataBufferByte.java:92)
    at java.awt.image.ComponentSampleModel.createDataBuffer(ComponentSampleModel.java:445)
    at java.awt.image.Raster.createWritableRaster(Raster.java:941)
    at javax.imageio.ImageTypeSpecifier.createBufferedImage(ImageTypeSpecifier.java:1074)
    at javax.imageio.ImageReader.getDestination(ImageReader.java:2892)
    at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1309)
    at com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1606)
    at javax.imageio.ImageIO.read(ImageIO.java:1448)
    at javax.imageio.ImageIO.read(ImageIO.java:1400)
    at greenfoot.util.GraphicsUtilities.loadCompatibleTranslucentImage(GraphicsUtilities.java:234)
    at greenfoot.GreenfootImage.loadURL(GreenfootImage.java:274)
    at greenfoot.GreenfootImage.loadFile(GreenfootImage.java:301)
    at greenfoot.GreenfootImage.<init>(GreenfootImage.java:108)
    at greenfoot.Actor.setImage(Actor.java:436)
    at win.act(win.java:46)
    at greenfoot.core.Simulation.actWorld(Simulation.java:610)
    at greenfoot.core.Simulation.runOneLoop(Simulation.java:545)
    at greenfoot.core.Simulation.runContent(Simulation.java:221)
    at greenfoot.core.Simulation.run(Simulation.java:211)
java.lang.OutOfMemoryError: Java heap space
danpost danpost

2018/4/5

#
1028x7800 is HUGE. It is no wonder memory is used up. Reduce the size (drastically) or break it up into parts to display one after another.
Agent40 Agent40

2018/4/6

#
Sadly Greenfoot as an engine can't handle files that size, so you'll just have to split up the image and work from there. No scrolling credits for you.
You need to login to post a reply.