Out of memory error when it makes no sense

I got these errors in ERA:

Error Name: Out Of Memory Error
Occurrences: 4
First Occurrence: 2022-12-12
Last Occurrence: 2023-01-04
Devices:
fēnix® 6 Pro / 6 Sapphire / 6 Pro Solar / 6 Pro Dual Power / quatix® 6: 23.10
fēnix® 6X Pro / 6X Sapphire / 6X Pro Solar / tactix® Delta Sapphire / Delta Solar / Delta Solar - Ballistics Edition / quatix® 6X / 6X Solar / 6X Dual Power: 23.10
 fēnix® 7X / tactix® 7 / quatix® 7X Solar / EnduroTm 2: 10.44
App Versions: 2.1.0
Languages: pol, slo, spa
Backtrace:
FitContributor.initialize:58
Field.initialize:602
MyApp.initialize:23

from the stacktrace I see that this is the very start of the app, when each object is created, but nothing more happens*, so in every device the same amount of memory should be allocated (no user input or preferences are read), and since I know that the app works on real fenix6 this makes no sense for fenix6pro, and even less for fenix7 that has 256K DF memory (as opposed to 32K for f6) to run out of memory at this point.

*) The only code that runs before this point that somehow could have different effect on different devices is this:
GenericChannel.initialize(method(:onMessage), new Ant.ChannelAssignment(Ant.CHANNEL_TYPE_RX_NOT_TX, Ant.NETWORK_PLUS));

What can cause this? Is it possible that the device starts the DF even though it has not enough memory to give it the amount "promised" by Garmin?

class MyApp extends Application.AppBase {
	var mSensor as Sensor;
    var mField as Field;
    function initialize() {
        var sensor = new Sensor();
        mSensor = sensor;
        mField = new Field(sensor);
    }
}

class Sensor extends Ant.GenericChannel {
    const DEVICE_TYPE = 0x78; // Heart Rate Sensors - 120

    // PERIODS: 4Hz: 8070, 2Hz: 16140, 1Hz: 32280
    const PERIOD = 32280;

    public var deviceCfg as DeviceConfig; 
    public var data as Data;
    public var searching as Number? = null;

    public function initialize() {
        try {
            GenericChannel.initialize(method(:onMessage), new Ant.ChannelAssignment( // removing "Ant." saves 4 bytes, but adds warning
                Ant.CHANNEL_TYPE_RX_NOT_TX, // Bidirectional Receive (Slave)
                Ant.NETWORK_PLUS)
            );
        } catch(e instanceof Ant.UnableToAcquireChannelException) {
            logRelease(e.getErrorMessage() as String);
            searching = -1;
        }

        data = new Data(); // doesn't even have initialize(), just a few class variables

        // Set the configuration
        deviceCfg = new Ant.DeviceConfig( {
            :deviceNumber => -1,                   // Set to 0 to use wildcard search
            :deviceType => DEVICE_TYPE,            // Heart Rate Sensors: 0x78 = 120
            :transmissionType => 0, // Set to 0 to use wildcard search
            :messagePeriod => PERIOD,              // 4Hz: 8070, 2Hz: 16140, 1Hz: 32280
            :radioFrequency => 57,                 // Ant+ Frequency 2.457GHz
            :searchTimeoutLowPriority => 10,       // Timeout in 25s
            :searchThreshold => 0} );              // Pair to all transmitting sensors
    }
}

class Field extends WatchUi.DataField {
    protected var mSensor as Sensor;
    public function initialize(sensor as Sensor) {
        mSensor = sensor;
        mFitContributor = new FitContributor(self);
        handleSettingUpdate();
    }
}

class FitContributor {
    (:typecheck(false))
    public function initialize(dataField as DataField) {
        var bpm = "bpm";
        var heart_rate = "ANT_HR";
        mCurrentHRField        = dataField.createField(heart_rate,       CURR_HR_FIELD_ID,      Fit.DATA_TYPE_UINT8,  { :mesgType=>Fit.MESG_TYPE_RECORD,  :units=>bpm});
    }
}
  • I see the .set files in the sim.  There's a settings folder right under Garmin, but that's not the correct folder.  You want to look in garmin/apps/settings

  • Many thanks for the screenshot, I was not looking at the good folder at all...

  • TL;DR the 8 KB settings limit doesn't seem to apply to newer devices like Fenix 6 Pro, which was specifically mentioned in the OP.

    To get a feel for how large settings are, look on a device in the garmin\apps\settings folder for the .set file.

    And the 8k is a max.  Not a constant.  If the code and data itself if 25kb, and the max size is 28kb (as is the case for data fields on a number of devices (32kb-4kb)), it's only got 3k when loading settings.  Even if the 8k settings still fit, the next time you use a bit more memory in the app, you could get the out-of-memory.

    It's not that I don't believe you, but I'm not sure what you're trying to say here, in the context of your previous comments.

    First you said (if I'm not mistaken), that you don't think Gavriel's app is hitting the total app memory limit (e.g. 256 KB for a Fenix 6 Pro data field), but that it's hitting the 8 KB properties/settings limit. Now you are talking about the total app memory limit (28 KB for data fields on some devices.) You don't have to explain to us how to do simple math like 28 - 25 = 3 lol.

    And I never said I thought "the 8k is a constant". What I said was I did a test with settings that are *larger* than 8k max and the simulator did not throw an error. Again, not that I don't believe you, but sometimes I need to see things with my own eyes.

    Anyway, I just had to try for myself, so I created properties/settings with 42 strings of 240 characters each. I ran the data field app in the sim for 945 LTE and it didn't crash. I tried changing all the settings to be 241 characters (to make sure all the settings are non-default), and it still worked. According to the memory viewer, the total app settings size was 12731 bytes.

    One thing that initially confused me is that the SET file in Windows and macOS was only about 1-2 KB, even after I changed the settings to be different from the defaults (and with a total size of 12731 bytes). I looked closer and saw that the FIT file has rudimentary "compression", where duplicate values are folded. So I went back and changed each setting to have a unique value.

    On a simulated 235 (with the old AppBase.getProperty() call), the settings were reset to default (which might look like a crash on a real device, I'm not sure.) This goes back to what you said about the 8 KB limit on the old object store.

    On a simulated Fenix 6 pro, the settings were preserved and I ended up with a SET file of 12 KB.

    I also tried:

    - Real 945 LTE (sideloaded). (Of course in this case I could only test with the default property values, and the size of the app .SET file was only 1.3 KB on the device so perhaps this was not a valid test)
    - Real 945 LTE (beta app). I tried with both default settings and custom settings. With my custom settings, the .SET file on the device was 8.43 KB (8633 bytes)

    No crashes. Again, not that I don't believe you, but I'm trying to understand the specifics of how a crash could occur in that way (with settings > 8k), on a Fenix 6 Pro.

    The old object store also had a max of 8kb, BTW.

    But does that pertain to Gavriel's crash on a Fenix 6 Pro?

    Most are changing settings while and app is running.

    Does that pertain to this issue and what you said earlier? That sounds like a normal "Out of Memory" situation where the total app memory is exceeded, as opposed to what you said about an 8k properties max.

  • On a simulated 235 (with the old AppBase.getProperty() call), the settings were reset to default (which might look like a crash on a real device, I'm not sure.) This goes back to what you said about the 8 KB limit on the old object store.

    Maybe if I have time I'll try this on a real device. I didn't see anything in the sim's CIQ_LOG.YML tho.

    Still doesn't seem to pertain the problem in the OP.

  • Thanks for the effort. Maybe we'll need to wait for some input from Garmin...

  • I've also been getting some unexpected out of memory errors lately on my device.  It's impacting watch faces I made and one made by another developer.  I'd love to learn that there's something I can do to improve my own apps, but given that the same error is taking down multiple apps at once (including one I didn't build) AND that this just started happening in the last few days, I'm wondering if this is a Garmin issue.


    Here's my post:
    forums.garmin.com/.../multiple-watch-faces-crashing-simultaneously-with-out-of-memory-error-minimal-repro-app-included