1 Reply Latest reply: Sep 28, 2007 2:15 AM by 807557 RSS

    ScopedMemory problems with ServerSocket


      i dont know if i am understanding these ScopedMemory right...

      Thats a part of my Code:

      public static void main(String[] args) {
      new RealtimeThread(){
      public void run(){
      LTMemory mem = new LTMemory(1024*16,1024*16);
      mem.enter(new Runnable(){
      public void run() {
      port = 9000;
      ServerSocketChannel serverChannel;
      try {
      serverChannel = ServerSocketChannel.open();
      serverChannel.socket().bind(new InetSocketAddress(port));
      } catch (IOException e) {
      System.out.println("Couldnt bind port: "+port);
      while (true){
      SocketChannel socketChannel = serverChannel.accept();
      TestThread testThread = new TestThread(socketChannel);
      }catch(Exception e){
      if (serverChannel.isOpen()){
      System.out.println("error ");
      System.out.println("ServerSocket on port "+port+" caught an error. aborting");

      TestThread is a class which implements Runnable, but every time i got that exception:

      Exception in thread "main" java.lang.IllegalArgumentException: Illegal Memory Area Passed or argument allocated in heap

      at javax.realtime.RealtimeThread.<init>(RealtimeThread.java:219)
      at javax.realtime.RealtimeThread.<init>(RealtimeThread.java:196)
      at javax.realtime.RealtimeThread.<init>(RealtimeThread.java:130)
      at javax.realtime.RealtimeThread.<init>(RealtimeThread.java:76)

      Anybody an idea what i am doing wrong with that?

        • 1. Re: ScopedMemory problems with ServerSocket
          Sorry for the delay in responding ... with forum notifications disabled for a while I only just realized there was something here.

          First can you try and use code tags to format your code sample as it is very hard to read.

          Second the error relates to the creation of a RealtimeThread which you don't seem to show. You say TestThread is a Runnable but you call start() on it so I assume it is really a Thread. The error you mention typically comes from creation of a NoHeapRealtimeThread when either no explicit initial memory area is given, or one of the passed in parameters was actually allocated in the heap.

          Can you give the full stacktrace? The parts I'm seeing don't quite make sense to me.

          David Holmes