these are the errors I keep on getting:
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
Exception in thread "RMI TCP Connection(3)-127.0.0.1" java.lang.OutOfMemoryError: Java heap space
Exception in thread "RMI RenewClean-" java.lang.OutOfMemoryError: Java heap space
Exception in thread "RMI TCP Connection(idle)" java.lang.OutOfMemoryError: Java heap space
I have several menu actors all with the same code except with different names, my question is how to avoid the heap space error, and is it a code problem or something else?
Thanks! :)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.awt.Color; /** * Write a description of class Levels here. * * @author (your name) * @version (a version number or a date) */ public class Levels extends Buttons { private static final Color transparent = new Color( 0 , 0 , 0 , 0 ); private GreenfootImage background; /** * Create a new counter, initialised to 0. */ public Levels() { background = getImage(); // get image from class setImage( "invisoButton.png" ); updateImage(); } /** * Act - do whatever the Levels wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { click(); } public void click() { if (Greenfoot.mouseClicked( this )) { getWorld().removeObjects(getWorld().getObjects(Controls. class )); getWorld().removeObjects(getWorld().getObjects(Credits. class )); getWorld().removeObjects(getWorld().getObjects(Settings. class )); Level1 level1 = new Level1(); getWorld().addObject(level1, 100 , 375 ); Ready ready = new Ready(); getWorld().addObject(ready, 500 , 375 ); Back back = new Back(); getWorld().addObject(back, 100 , 375 ); setLocation( 175 , 75 ); } } /** * Update the image on screen to show the current value. */ private void updateImage() { GreenfootImage image = new GreenfootImage(background); GreenfootImage text = new GreenfootImage( "Levels" , 44 , Color.BLACK, transparent); image.drawImage(text, (image.getWidth()-text.getWidth())/ 2 ,(image.getHeight()-text.getHeight())/ 2 ); setImage(image); } } |