I also had other memory leaks that I have resolved. Of note is that they did not show in the simulator, but occur on my device (920XT). I think the simulator should be made to recognize these problems.
Forgot to mention. To see the leak you must run on your device, and scroll through the pages. Each time you reenter a page the used memory will be greater.
Primates.mc
function onStart() {
var key = 0;
var value = getProperty(key);
if(null != value) {
deleteProperty(key);
value = 0;
}
setProperty(key,value);
}
PrimatesView.mc
function onUpdate(dc)
{
dc.setColor( Gfx.COLOR_TRANSPARENT, Gfx.COLOR_BLACK );
dc.clear();
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_BLACK);
dc.fillRectangle(0, 0, dc.getWidth(), dc.getHeight());
dc.setColor( color, Gfx.COLOR_TRANSPARENT );
dc.drawText(5, 5, Gfx.FONT_SMALL, primates[index], Gfx.TEXT_JUSTIFY_LEFT);
dc.drawBitmap(25, 30, bitmap);
indicator.draw(dc, index);
dc.setColor( Gfx.COLOR_BLACK, Gfx.COLOR_BLACK );
var _text = "Usedmem: " + System.getSystemStats().usedMemory;
dc.fillRectangle(0,0,218,22);
dc.setColor(Gfx.COLOR_WHITE,Gfx.COLOR_BLACK);
dc.drawText(0, 0, Gfx.FONT_TINY, _text, Gfx.TEXT_JUSTIFY_LEFT);
}
PrimatesDelegate.mc // Handlers for those without touchscreen
function onKey(event) {
var key = event.getKey();
if(Ui.KEY_UP == key) {
onPreviousPage();
}
else if(Ui.KEY_DOWN == key) {
onNextPage();
}
else if(Ui.KEY_ESC == key) {
Ui.popView(Ui.SLIDE_IMMEDIATE);
}
return true;
}