Ticket Created
over 3 years ago

CIQQA-637

repeated makeImageRequest calls cause memory leak

I'm running a widget that makes repeated makeImageRequest calls and am noticing memory consumption go

up by 0.1 to 0.2kB for each call.  Looks like a memory leak. I'm using Connect IQ SDK 4.0.3 and users are reporting out of memory crashes.

I tried the widget app with every watch model in the simulator and the problem occurs on every model except Venu2 and Venu2s.  

Incidentally the widget app under Venu2 and Venu2s takes extremely little memory to run compared to other models.  I'm not sure why.

Parents
  • I still don't see the problem.  I made a simple test project to demonstrate the problem.  Just create a default Widget project and paste this code in the view, and run.

    import Toybox.Graphics;

    import Toybox.WatchUi;

    import Toybox.Timer;

    class PhotoWidView extends WatchUi.View {

    var image;

        function initialize() {

            View.initialize();

        }

        function onShow() as Void {

        triggerRequest();

        }

        

        function onLayout(dc as Dc) as Void {

        var myTimer = new Timer.Timer();

        myTimer.start(method(:timerCallback), 1000, true);

        }

        

    function timerCallback() {

        triggerRequest();

    WatchUi.requestUpdate();

    }

        function responseCallback(responseCode, data) {

            responseCode = responseCode;

            image=null;

            if (responseCode == 200) {

                image = data;

            } 

        }

        

    function triggerRequest() {

            var url = "">encrypted-tbn0.gstatic.com/images;

            var options =  {          

                 :palette => [0x00000,

    0x555555,

    0xaaaaaa,

    0xaa0000,

            0xff5500,

            0x55aa00,

            0x5500ff,

            0xaa5500,

            0xffffff],

              :maxWidth => 240,        // set the max width

                :maxHeight => 240,        // set the max height

                :dithering => Communications.IMAGE_DITHERING_NONE   // set the dithering

            };

            Communications.makeImageRequest(url, null, options, method(:responseCallback));

        }    

        

        function onUpdate(dc as Dc) as Void {

            View.onUpdate(dc);

            if (image!=null) {

            dc.drawBitmap(0,0,image);

            }

        }

        function onHide() as Void {

        }

    }

Comment
  • I still don't see the problem.  I made a simple test project to demonstrate the problem.  Just create a default Widget project and paste this code in the view, and run.

    import Toybox.Graphics;

    import Toybox.WatchUi;

    import Toybox.Timer;

    class PhotoWidView extends WatchUi.View {

    var image;

        function initialize() {

            View.initialize();

        }

        function onShow() as Void {

        triggerRequest();

        }

        

        function onLayout(dc as Dc) as Void {

        var myTimer = new Timer.Timer();

        myTimer.start(method(:timerCallback), 1000, true);

        }

        

    function timerCallback() {

        triggerRequest();

    WatchUi.requestUpdate();

    }

        function responseCallback(responseCode, data) {

            responseCode = responseCode;

            image=null;

            if (responseCode == 200) {

                image = data;

            } 

        }

        

    function triggerRequest() {

            var url = "">encrypted-tbn0.gstatic.com/images;

            var options =  {          

                 :palette => [0x00000,

    0x555555,

    0xaaaaaa,

    0xaa0000,

            0xff5500,

            0x55aa00,

            0x5500ff,

            0xaa5500,

            0xffffff],

              :maxWidth => 240,        // set the max width

                :maxHeight => 240,        // set the max height

                :dithering => Communications.IMAGE_DITHERING_NONE   // set the dithering

            };

            Communications.makeImageRequest(url, null, options, method(:responseCallback));

        }    

        

        function onUpdate(dc as Dc) as Void {

            View.onUpdate(dc);

            if (image!=null) {

            dc.drawBitmap(0,0,image);

            }

        }

        function onHide() as Void {

        }

    }

Children