Device Memory

Hi All,

Not sure if this has been asked before - had a look but could not find. 

What is the best way to restrict app features depending on device memory limits so as not to go over the max memory of a device?

Will unused code for features not available in lower memory devices take up memory?

Thanks,

Hannes

  • You probably want to use Jungles https://developer.garmin.com/connect-iq/reference-guides/jungle-reference/#junglereferenceguide

    You can use annotations in your code, or even use different source files for things based on the device.

    In most cases, even if you have code that's never called, it will still be included in an apps total memory unless you use jungles.

  • You can add features for different devices according to its memory limit.

    memoryLimit are queried here in a json file
    ~t/Library/Application Support/Garmin/ConnectIQ/Devices/{device}/compiler.json
    You can write a script to automaticaly add the source by memory limit. It is possible.
    My py script as you reference.

    Will unused code for features not available in lower memory devices take up memory?

    If the code is unused, don't include it in the source for that device.

    file arch

    ├── source-base
    │ └── QingYuAnView.mc
    ├── source-bodybattery
    │ └── BodyBattery.mc
    ├── source-spo2
    │ └── Spo2.mc

    Make declaritions for all the methods

    (:base)
    function drawSpo2InGrid() {}
    (:base)
    function drawNearArcSpo2() {}

    monkey.jungle

    base.excludeAnnotations = base
    marq2aviator.sourcePath = $(marq2aviator.sourcePath);source-spo2;source-sunriseset;source-gw;source-bodybattery;source-stresslevel;source-elevation;source-pressure;source-thermometer;source-round-390x390
    fr245.sourcePath = $(fr245.sourcePath);source-sunriseset;source-gw;source-bodybattery;source-stresslevel;source-round-240x240-a
    You can see fr245 has less source-*

    in view code

     
          if ($ has :Spo2 && Spo2 has :drawSpo2InGrid) {
            Spo2.drawSpo2InGrid(
              gridX,
              y1,
              y2,
              dc,
              colorArray,
              smallCharFont,
              screenHeight
            );
          }
  • & Thanks for your replies. Will try that out. Hannes