Simulator memory crash when accessing menu (7.1.1)

Dear all,

I am confronted with a bug I cannot understand.

With Fenix 5 and 6 (Fenix 7 looks ok) when I access the app menu for the third time, app crashes.

It crashes when loading resource for the menu.addItem, new CustomIcon. Code is below.

"Object usage" and "peak object" shown in the active memory tool increases after each time I access the menu.

Any idea?

 

  class CustomIcon extends WatchUi.Drawable {

    var bitmapResource = null;
        public function initialize(resourceId) {
            Drawable.initialize({});
            bitmapResource = WatchUi.loadResource(resourceId);
            }  

        public function draw(dc) as Void {
            dc.setColor(Graphics.COLOR_TRANSPARENT, Graphics.COLOR_TRANSPARENT);
            dc.clear();
            dc.drawBitmap(0, 0, bitmapResource);
            }
}
  • Forgot to write the error message;

    Error: Out Of Memory Error Details: Failed invoking <symbol> Stack: - initialize() at C:\Users\jeann\OneDrive\Desktop\ProVario\source\AccelMagDelegate.mc:117 0x10001614 - onMenu() at C:\Users\jeann\OneDrive\Desktop\ProVario\source\AccelMagDelegate.mc:255 0x10001bc6 - handleEvent() at D:\grmn\prj\di\connectiq\toolchain\mbsimulator\submodules\technology\monkeybrains\virtual-machine\api\WatchUi.mb:1250 0x300025a2

  • I found the problem. My code in the OnMenu() was missing that:

    var menu = new WatchUi.Menu2({:title=>"Setting"});