This discussion is archived
2 Replies Latest reply: Jul 8, 2010 7:44 PM by 807557 RSS

About Scoped Memory Size

807557 Newbie
Currently Being Moderated
Hello;
I am using JRTS newly. I have a question. I have wrote a simple code about scoped memory size. It is below
import javax.realtime.LTMemory;
import javax.realtime.RealtimeThread;
import javax.realtime.ScopedMemory;

public class Test extends RealtimeThread{
     
     /**
      * @param args
      */
     
     public void run(){
          final ScopedMemory outerScoped = new LTMemory(1000);
          System.out.println("outerScoped.memoryConsumed() "+outerScoped.memoryConsumed());
          System.out.println("outerScoped.memoryRemaining() "+outerScoped.memoryRemaining());
          System.out.println("outerScoped.getMaximumSize() "+outerScoped.getMaximumSize());
          
     
     }
     
     
     
     public static void main(String[] args) {
          Test test = new Test();
          
          test.start();
          
          try {
               test.join();
          } catch (InterruptedException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          }     
          
     }

}

Output is

outerScoped.memoryConsumed() 0
outerScoped.memoryRemaining() 16384
outerScoped.getMaximumSize() 1000
Consumed is 0(normal)
Max is 1000 normal
But Remaining 16384 why? I have setted 1000 byte. Why does remaining 16384. It must be 1000

Best Regards,
  • 1. Re: About Scoped Memory Size
    807557 Newbie
    Currently Being Moderated
    Hi,

    Please have a look at the scoped memory related section in the technical information document:
    http://java.sun.com/javase/technologies/realtime/reference/doc_2.2u1/release/JavaRTSTechInfo.html#scoped-mem

    For your specific question, search for ScopedMemoryAllocGrain.

    Regards,

    Bertrand.
  • 2. Re: About Scoped Memory Size
    807557 Newbie
    Currently Being Moderated
    There is a bug here as well: getMaximumSize() should return the actual maximum as size() returns the actual size, not the value passed to the constructor. It should always be the case that size() <= getMaximumSize()

    David Holmes
    Oracle