Thread: [HELP] Caused by: java.lang.OutOfMemoryError: Java heap space

Results 1 to 4 of 4
  1. #1 [HELP] Caused by: java.lang.OutOfMemoryError: Java heap space 
    Registered Member
    netzo's Avatar
    Join Date
    Feb 2008
    Age
    28
    Posts
    1,226
    Thanks given
    402
    Thanks received
    135
    Rep Power
    185
    Code:
    Error starting the server...
    java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space
    	at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source)
    	at java.util.concurrent.FutureTask.get(Unknown Source)
    	at server.util.BlockingExecutorService.waitForPendingTasks(BlockingExecutorService.java:50)
    	at server.RS2Server.start(RS2Server.java:50)
    	at server.Server.run(Server.java:81)
    	at java.lang.Thread.run(Unknown Source)
    	at server.Server.main(Server.java:61)
    Caused by: java.lang.OutOfMemoryError: Java heap space
    	at server.core.worldmap.WalkingHandler$TiledMap.<init>(WalkingHandler.java:63)
    	at server.core.worldmap.WalkingHandler.<init>(WalkingHandler.java:15)
    	at server.core.worldmap.WalkingHandler.<init>(WalkingHandler.java:14)
    	at server.core.worldmap.WalkingHandler$SingletonContainer.<clinit>(WalkingHandler.java:19)
    	at server.core.worldmap.WalkingHandler.getSingleton(WalkingHandler.java:23)
    	at server.core.World$6.call(World.java:129)
    	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    	at java.util.concurrent.FutureTask.run(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)
    any idea what could cause it?
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  2. #2  
    q.q


    Join Date
    Dec 2010
    Posts
    6,535
    Thanks given
    1,072
    Thanks received
    3,534
    Rep Power
    4752
    the server can't reserve enough memory for the requirements of this line

    Code:
    at server.core.worldmap.WalkingHandler$TiledMap.<init>(WalkingHandler.java:63)
    is my guess
    Reply With Quote  
     

  3. #3  
    Registered Member
    netzo's Avatar
    Join Date
    Feb 2008
    Age
    28
    Posts
    1,226
    Thanks given
    402
    Thanks received
    135
    Rep Power
    185
    Quote Originally Posted by Harlan View Post
    the server can't reserve enough memory for the requirements of this line

    Code:
    at server.core.worldmap.WalkingHandler$TiledMap.<init>(WalkingHandler.java:63)
    is my guess
    This is my WalkingHandler.java
    Code:
    package server.core.worldmap;
    
    import java.io.RandomAccessFile;
    import java.nio.MappedByteBuffer;
    import java.nio.channels.FileChannel;
    
    public class WalkingHandler {
    
    	public static final int WIDTH = 12000;
    	public static final int HEIGHT = 9900;
    
    	private final TiledMap map;
    
    	private WalkingHandler() {
    		this.map = new TiledMap(WIDTH, HEIGHT);
    	}
    
    	private static class SingletonContainer {
    		private static final WalkingHandler SINGLETON = new WalkingHandler();
    	}
    
    	public static WalkingHandler getSingleton() {
    		return SingletonContainer.SINGLETON;
    	}
    
    	public boolean traversable(int x, int y, int direction) {
    		int flag = map.getFlag(x, y);
    		//System.out.println(direction);
            if (direction == 0 && (flag == 1 || flag == 4 || flag == 6 || flag == 7 || flag == 9 || flag == 11 || flag == 13 || flag == 14)) {
                return false;
            } else if (direction == 4 && (flag == 1 || flag == 7 || flag == 15 || flag == 10 || flag == 11 || flag == 12 || flag == 14 || flag == 5)) {
                return false;
            } else if (direction == 8 && (flag == 1 || flag == 2 || flag == 3 || flag == 4 || flag == 5 || flag == 6 || flag == 7 || flag == 12)) {
                return false;
            } else if (direction == 12 && (flag == 1 || flag == 3 || flag == 6 || flag == 9 || flag == 10 || flag == 11 || flag == 12 || flag == 8)) {
                return false;
            } else if(flag > 0 && flag < 15) {
    			return false;
    		}
            return true;
    	}
    
    	public void initialize() throws Exception {
    		long delta = System.currentTimeMillis();
    		RandomAccessFile raf = new RandomAccessFile("./Data/data/Map.bin", "r");
    		FileChannel channel = raf.getChannel();
    		MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
    		int length = buffer.getInt();
    		for(int i = 0; i < length; i++) {
    			int x = buffer.getShort();
    			int y = buffer.getShort();
    			byte flag = buffer.get();
    			map.flag(x, y, flag);
    		}
    		System.out.println("Loaded clipmap in " + (System.currentTimeMillis() - delta) + "ms.");
    	}
    
    	private static class TiledMap {
    	
    		private final byte[] plane;
    
    		public TiledMap(int width, int height) {
    			this.plane = new byte[width * 10000 + height];
    		}
    
    		public int getFlag(int x, int y) {
    			return plane[x * 10000 + y];
    		}
    
    		public void flag(int x, int y, byte flag) {
    			this.plane[x * 10000 + y] = flag;
    		}
    
    	}
    
    }
    and this is line 63

    Code:
    this.plane = new byte[width * 10000 + height];
    method

    Code:
    		public TiledMap(int width, int height) {
    			this.plane = new byte[width * 10000 + height];
    		}
    btw I use eclipse.
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  4. #4  
    q.q


    Join Date
    Dec 2010
    Posts
    6,535
    Thanks given
    1,072
    Thanks received
    3,534
    Rep Power
    4752
    try lowering your width/height, your giving that byte array an incredibly high index
    Reply With Quote  
     

  5. Thankful user:



Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [pi] outofmemoryerror: java heap space
    By thebobbykinney in forum Help
    Replies: 0
    Last Post: 12-05-2010, 07:10 PM
  2. OutOfMemoryError: Java Heap Space
    By Mikey` in forum Help
    Replies: 6
    Last Post: 07-29-2010, 08:40 AM
  3. Replies: 14
    Last Post: 06-30-2010, 05:59 PM
  4. OutOfMemoryError: Java heap space
    By Mikey` in forum Help
    Replies: 5
    Last Post: 06-09-2010, 01:55 PM
  5. Replies: 9
    Last Post: 03-30-2009, 12:39 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •