0

I am developing a watch app for a Garmin Vivoactive HR that will send data to the phone periodically (using ConnectIQ SDK V2.3.4).

The available memory drops as the Communications.transmit(...) function is called repeatedly until the app crashes on low memory.

I have tested my app with the transmit() call commented out and the problem does not occur, so I think it is either a memory leak in the transmit() function or there is an (as far as I can tell) undocumented need to do something to release memory after the transmit() call.

The relevant piece of my test code is here:

     function initialize() {
    View.initialize();
    listener = new Comm.ConnectionListener();
  }

function timerCallback() {
  var dataObj = {
    "HR"=> 60,
    "X" => 0,
    "Y" => 0,
    "Z" => 0
  };
  // FIXME - THIS CRASHED WITH OUT OF MEMORY ERROR AFTER 5 or 10 minutes.
  Comm.transmit(dataObj,null,listener);
  Ui.requestUpdate();
}


  // Load your resources here
  function onLayout(dc) {
    width = dc.getWidth();
    height = dc.getHeight();
    myTimer = new Timer.Timer();
    myTimer.start(method(:timerCallback), 1000, true);
  }

Complete test app that displays the available memory on the watch screen as it runs is here: https://github.com/OpenSeizureDetector/Garmin_SD/tree/master/MemTest

I can only test this on a Vivoactive HR device, because I can't get the linux version of the garmin simulator working. It looks like it is similar to an earlier problem that Garmin apparently fixed (https://forums.garmin.com/forum/developers/connect-iq/100499-periodic-ble-transmit-causes-memory-leak), but I don't seem to be able to log into the Garmin forums to report it there.

Does anyone know if I am doing something wrong and should be asking to release memory or does this look like a bug in the Communications.transmit() function of the SDK?

1 Answers1

0

try this

   Comm.transmit(dataObj,null,listener);
   dataObj = null;
  • 1
    Hi, and welcome to SO! Can you explain the logic behind your answer, and not just provide code? – Max von Hippel Mar 16 '18 at 20:27
  • here it's hard to explain something, maybe it's in a not very well organized monkey garbage collector – evgeniodev Mar 16 '18 at 21:04
  • 1
    Haha I understand. That said, making an effort to explain the logic has a "teach a man to fish" sort of effect of helping the user see how to problem solve on their own, and so if you can find a way to do so it's worth doing and will less to more people up voting your contributions. – Max von Hippel Mar 16 '18 at 21:09
  • Hi, Thank you for the suggestion. Unfortunately it still crashes on low memory if I leave it running over night. – Graham Jones Mar 27 '18 at 21:08