void doWork() { int x = 0, y = 0; Memory memory = Memory.getCurrentMemoryArea(); devices.Console.println("Thread 1 allocating in: " + memory.getName()); y = memory.consumedMemory(); while (count < 5) { x = memory.consumedMemory(); if (x != y) { devices.Console.println("T1 Fail 1"); fail = true; } new SmallObject(); y = memory.consumedMemory(); if (y != x + sizeOfSmallObject) { devices.Console.println("T1 Fail 2, y = " + y + ", x = " + x); fail = true; } count++; delay(); } }
public static void main(String[] args) { Memory memory = Memory.getHeapArea(); new SmallObject(); int x = memory.consumedMemory(); new SmallObject(); int y = memory.consumedMemory(); sizeOfSmallObject = y - x; x = memory.consumedMemory(); new BiggerObject(); y = memory.consumedMemory(); sizeOfBiggerObject = y - x; devices.Console.println("small object is " + sizeOfSmallObject + " bytes"); devices.Console.println("bigger object is " + sizeOfBiggerObject + " bytes"); Const.setDefaultErrorReporter(); vm.Memory.startMemoryAreaTracking(); storageParameters_Sequencer = new StorageParameters( Const.OUTERMOST_SEQ_BACKING_STORE, Const.PRIVATE_MEM, Const.IMMORTAL_MEM, Const.MISSION_MEM); storageParameters_Handlers = new StorageParameters(Const.PRIVATE_BACKING_STORE, 2002, 0, 0); configParameters = new ConfigurationParameters(null, -1, -1, new long[] {Const.HANDLER_STACK_SIZE}); devices.Console.println("\n********** TestSCJThreadMemory main.begin ******************"); new LaunchLevel2(new MyApp()); devices.Console.println("********* TestSCJThreadMemory main.end ********************"); if (!fail) { args = null; } }