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! :)
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); } }