Vivoactive HR switchToView memory leak !!

Former Member
Former Member
I've discovered memory leak of main functionality on Vivoactive HR device. FW 3.30

The problem can be seen on youtube:
https://youtu.be/To3fIsjdQw4


There are two simple Pages (Views). Problem was when I tried switch page by following methods:

function SwitchToPage(newIndex) {
_index = newIndex;
if (_index == 0) {
Ui.switchToView(new MainPage(), new MainDelegate(_index), Ui.SLIDE_LEFT);
} else {
Ui.switchToView(new ExtraInfoPage(), new MainDelegate(_index), Ui.SLIDE_LEFT);
}
}



So .I've prepared simple test application to reproduce it:

Testleak.mc
using Toybox.Application as App;
using Toybox.WatchUi as Ui;


class test_leakApp extends App.AppBase {

function initialize() {
AppBase.initialize();
}

function getInitialView() {
return [ new MainPage(), new MainDelegate(0) ];
}
function mainTimerHandler() {
Ui.requestUpdate();
}
}



MainPage.mc
using Toybox.WatchUi as Ui;
using Toybox.Graphics as Gfx;
using Toybox.System as Sys;


class MainPage extends Ui.View {


function initialize() {
View.initialize();
}

function onUpdate(dc) {
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_BLACK);
dc.clear();
var stats = Sys.getSystemStats();
dc.drawText(60, 20, Gfx.FONT_SYSTEM_MEDIUM, "Mem: " + stats.usedMemory.format( "%d" ), Gfx.TEXT_JUSTIFY_CENTER);
}
}


ExtraInfoPage.mc
using Toybox.WatchUi as Ui;
using Toybox.Graphics as Gfx;
using Toybox.System as Sys;


class ExtraInfoPage extends Ui.View {

function initialize() {
View.initialize();
}

function onUpdate(dc) {
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_BLACK);
dc.clear();

var stats = Sys.getSystemStats();
dc.drawText(60, 20, Gfx.FONT_SYSTEM_MEDIUM, "Mem: " + stats.usedMemory.format( "%d" ), Gfx.TEXT_JUSTIFY_CENTER);

var center = (dc.getWidth().toFloat() / 2.toFloat()).toNumber();
dc.setPenWidth(3);
dc.setColor(Gfx.COLOR_RED, Gfx.COLOR_TRANSPARENT);
dc.drawRoundedRectangle(center, 58, 3, 140, 5);
}
}


MainDelegate.mc
using Toybox.WatchUi as Ui;

const NO_PAGES = 2;


class MainDelegate extends Ui.BehaviorDelegate {

var _index = 0;

function initialize(idx) {
BehaviorDelegate.initialize();
_index = idx;
}

function onNextPage() {
var newIndex = _index + 1;
if (newIndex >= NO_PAGES) {
newIndex = 0;
}
SwitchToPage(newIndex);
return true;
}

function onPreviousPage() {
var newIndex = _index - 1;
if (newIndex < 0) {
newIndex = NO_PAGES - 1;
}
SwitchToPage(newIndex);
return true;
}

function SwitchToPage(newIndex) {
_index = newIndex;
if (_index == 0) {
Ui.switchToView(new MainPage(), new MainDelegate(_index), Ui.SLIDE_LEFT);
} else {
Ui.switchToView(new ExtraInfoPage(), new MainDelegate(_index), Ui.SLIDE_LEFT);
}
}

}


Regards
  • Hey,

    I'm struggling to reproduce this with the code that you've provided. I tried on both 3.30 and beta 3.38 sw version. The link to the video isn't working yet. Sometimes youtube will make you wait a full 24hrs after posting for it to be available to the public. I'll check back on it tomorrow and see if we can reproduce.

    Thanks,
    -Coleman
  • Former Member
    Former Member over 8 years ago
    Hey,

    I'm struggling to reproduce this with the code that you've provided. I tried on both 3.30 and beta 3.38 sw version. The link to the video isn't working yet. Sometimes youtube will make you wait a full 24hrs after posting for it to be available to the public. I'll check back on it tomorrow and see if we can reproduce.

    Thanks,
    -Coleman


    Sorry I forgot publish this video. Now is already available..

    Regards
  • Thank you for updating the video. There is something about how rapid the screen change is. I am now able to reproduce. We will open up a ticket to be prioritized this week.

    Thank you,
    -Coleman