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

2014/1/5

Greenfoot not responding to user commands

chrl98 chrl98

2014/1/5

#
When I try to make a selection to "Set Image" in Greenfoot, I get an "Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space" error. I know its related to too memory allocation, and I've restarted my computer, quit Greenfoot and relaunched it several times, but I still can't make any selections. I can open the editor, but I also cannot create new subclasses. The accompanying message is as follows: at java.awt.image.DataBufferByte.<init>(DataBufferByte.java:92) at java.awt.image.ComponentSampleModel.createDataBuffer(ComponentSampleModel.java:415) at java.awt.image.Raster.createWritableRaster(Raster.java:944) at javax.imageio.ImageTypeSpecifier.createBufferedImage(ImageTypeSpecifier.java:1073) at javax.imageio.ImageReader.getDestination(ImageReader.java:2896) at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1280) at com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1577) at javax.imageio.ImageIO.read(ImageIO.java:1448) at javax.imageio.ImageIO.read(ImageIO.java:1308) at greenfoot.gui.images.ImageLibList$ImageListEntry.loadPreview(ImageLibList.java:411) at greenfoot.gui.images.ImageLibList$ImageListEntry.<init>(ImageLibList.java:400) at greenfoot.gui.images.ImageLibList$ImageListEntry.<init>(ImageLibList.java:375) at greenfoot.gui.images.ImageLibList$ImageListEntry.<init>(ImageLibList.java:367) at greenfoot.gui.images.ImageLibList.setDirectory(ImageLibList.java:158) at greenfoot.gui.images.ImageLibList.<init>(ImageLibList.java:126) at greenfoot.gui.images.ImageLibFrame.buildUI(ImageLibFrame.java:193) at greenfoot.gui.images.ImageLibFrame.<init>(ImageLibFrame.java:142) at greenfoot.actions.SelectImageAction.actionPerformed(SelectImageAction.java:106) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) at javax.swing.AbstractButton.doClick(AbstractButton.java:376) at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833) at com.apple.laf.AquaMenuItemUI.doClick(AquaMenuItemUI.java:157) at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877) at java.awt.Component.processMouseEvent(Component.java:6505) at javax.swing.JComponent.processMouseEvent(JComponent.java:3321) at java.awt.Component.processEvent(Component.java:6270) at java.awt.Container.processEvent(Container.java:2229) at java.awt.Component.dispatchEventImpl(Component.java:4861) at java.awt.Container.dispatchEventImpl(Container.java:2287)
davmac davmac

2014/1/6

#
Try deleting the too-large image from your scenario (using your operating system utilities, i.e. from outside Greenfoot). The images are in the 'images' folder/directory inside the scenario.
chrl98 chrl98

2014/1/6

#
It worked. Thanks davmac, although the program still lags slightly due to the running of the code in my scenario. What do you think has caused this problem? Is it memory allocation, or something else?
davmac davmac

2014/1/7

#
the program still lags slightly due to the running of the code in my scenario. What do you think has caused this problem? Is it memory allocation, or something else?
Do you mean, what caused the initial problem, or the lag? If the lag, could you elaborate - when do you experience it?
chrl98 chrl98

2014/1/7

#
It's the initial problem, sorry for not clarifying, I already know what's causing the scenario to run slowly.
davmac davmac

2014/1/7

#
Well, what caused it is that you had an image which consumed all available memory. Greenfoot doesn't really handle this (Java just throws a general 'out of memory' exception as you saw, and Greenfoot doesn't normally try to handle that since it could happen anywhere and there's often nothing very sensible that can be done). So, the dialog isn't set up properly and doesn't respond to your input.
chrl98 chrl98

2014/1/7

#
Hmmm I see. Thanks for the explanation.
You need to login to post a reply.