Search Results

Search found 1 results on 1 pages for 'user1646684'.

Page 1/1 | 1 

  • Java ME Runnable object takes up memory although not made an instance yet

    - by user1646684
    I am facing a strange problem with memory in Java ME. here is a part of my code: int variable=1; while (true) { if (variable==2) { display = Display.getDisplay(this); MyCanvas mc = new MyCanvas(this); // MyCanvas is a runnable object mcT = new Thread(mc); // new thread for MyCanvas mc.repaint(); display.setCurrent(mc); mcT.start(); // run thread } if (variable==1) { // Do some other stuff } } The problem is that although still the variable is set to 1, so it does not come through the if (variable==2) condition the program consumes 300kB more memory than when I delete the code after condition if (variable==2). As far as I know the code should by executed and the objects shall be created only when I set variable to value 2. But it consumes the memory also when the code after condition "if (variable==2)" is not executed. Why does this happen?

    Read the article

1