简体   繁体   中英

Memory Leak on Garmin Vivoactive HR in BLE Transmit function

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?

try this

   Comm.transmit(dataObj,null,listener);
   dataObj = null;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM