Skip to content

potential memory leak using Q.QPromise #9

Description

@nenadlazovic

Hi I am experiencing memory leak in QML app using quickpromise.
I created simple app to demonstrate.
App have timer that does some async operation. async operation is handled using quickpromise.
Code below (with timer 1 sec), leaks approx 1.6MB/min, and eventually crashes (QT 5.11 @ MSWindows or Ubuntu 18)

Any suggestions ?

import QtQuick 2.5
import QtQuick.Window 2.2

import "promise.js" as Q

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World");
    property int syncStoriesTimeoutInSec: 1;

    Component.onCompleted: {
       syncStories();
    }

    Timer {
        id: syncStoriesTimer
        interval: syncStoriesTimeoutInSec * 1000;
        running: false; repeat: false
        onTriggered: {
            syncStories();
        }
    }

    function syncStories() {
        let p = Q.promise(function (resolve, reject) {
            //for test purposes, resolve right away
            resolve({});
        });

        p.then(
            function(data) {
                console.log("resolved");
                syncStoriesTimer.start();
            },
            function(data) {
                console.log("rejected");
            }
        )
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions