Memory usage

Former Member
Former Member
Hi
I've joined this community recently (March), made my way to learn MonkeyC lng and create some WatchFace and App. I'm developing mostly for Fenix 3 where after app became more complex I reached 64kB memory limit. I realize there are couple of options to optimize the code to save some memory. I saw post in this forum focused on this topic 2-3 months ago and now is gone. So can you share some advise on following:
1) using global or local variables?

2) Which one from the following examples is less memory demanding:
option: a
var a = getProperty("a");
var b = getProperty("b");
var c = a + b;
option: b
var c = getProperty("a") + getProperty("b");

3) Which way is better (in terms of memory saving) using Layouts, or define the page design in function onUpdate(dc) for each page?

4) Are there any ways how to clear memory?

Anything you consider to be mentioned in order to optimize memory usage appreciated. Thanks for answers.
  • For 1 and 2, the impact on size is minor. They are both more of a performance thing in my eyes (I only ever use getProperty in initialize and based on onSettingschanged, and not in onUpdate for example.

    for 3, layouts, in my experience will use more memory than direct dc calls, so using direct dc will save some

    for 4 an object goes away, it's memory is freed (and an object is freed), or you can set an object=null to free up memory.

    It sounds like you have a bigger problem, in that you have to free up a much of memory, and the best way to do that is look at reworking a few big things in your code.