QML Loader memory leak?

1.2k views Asked by At

My application starts to consume large amount of memmory. First shot was MNG animation cache, but it seams that they are just not shared. So I created a TestItem with debug print in constructor/destructor, and I saw that Loader not working property when its source is changed via Video stop signal:

import QtQuick 1.1
import QtMultimediaKit 1.1

Rectangle {
    id:root
    width: 800
    height: 480

    Video {
        id: video1
        anchors.fill: parent
        source: "test.mp4" 
        onStopped: {
            loader1.source= "Test2.qml";
        }
    }
    Loader {
        id:loader1
        onSourceChanged: {
            console.debug("source changed to "+source)
        }
    }
    MouseArea {
        anchors.fill: parent
        onPressed: {
            loader1.source= "Test1.qml";
            video1.play();
        }
    }
}

So when I click 4 times I get console output like this:

TestItem(0x1b4fc00) 
source changed to file:///opt/Test/qml/TestLoaderBug/Test1.qml
TestItem(0x2047ba0) 
source changed to file:///opt/Test/qml/TestLoaderBug/Test2.qml
TestItem(0x2046720) 
source changed to file:///opt/Test/qml/TestLoaderBug/Test1.qml
~ TestItem(0x2047ba0) 
TestItem(0x2050560) 
source changed to file:///opt/Test/qml/TestLoaderBug/Test2.qml
TestItem(0x204fad0) 
source changed to file:///opt/Test/qml/TestLoaderBug/Test1.qml
~ TestItem(0x2050560) 
TestItem(0x2051e40) 
source changed to file:///opt/Test/qml/TestLoaderBug/Test2.qml
TestItem(0x2051330) 
source changed to file:///opt/Test/qml/TestLoaderBug/Test1.qml
~ TestItem(0x2051e40) 
TestItem(0x2052e90) 
source changed to file:///opt/Test/qml/TestLoaderBug/Test2.qml

And when I close my application, all remaing object are deleted:

~ TestItem(0x1b4fc00) 
~ TestItem(0x2046720) 
~ TestItem(0x204fad0) 
~ TestItem(0x2051330) 
~ TestItem(0x2052e90) 

Why the onStopped signal may produce such behavior? Is there any fix for this?

Tested on Ubuntu 12.04 with libqt4-declarative(Version: 4:4.8.1-0ubuntu4.2) and libdeclarative-multimedia(Version: 1.2.0-1ubuntu2).

0

There are 0 answers