【发布时间】:2017-08-28 09:36:36
【问题描述】:
我注意到为 Image 分配的内存没有释放。
如果没有启动应用程序,系统具有以下内存值:423MiB / 1985MiB(通过 nvidia-smi 检查)
当我启动应用程序并单击(更改图像源)几次时,使用的内存正在增加(1 单击增加 4-5MB):1950MiB / 1985MiB
将“缓存”属性设置为 false 没有帮助。
我找到了解决方法:更改图像可见性,但在这种情况下需要很多图像项。
是否存在使用“源”属性而不是“可见”的解决方案?
qml 来源:
Image {
id: trg
anchors.fill: parent
cache: false
states: [
State {
name: "on"
PropertyChanges {
target: trg
source: "qrc:/1.png"
}
},
State {
name: "off"
PropertyChanges {
target: trg
source: "qrc:/2.png"
}
}
]
}
MouseArea {
property bool isOn: false
anchors.fill: parent
onClicked: {
if (isOn) {
trg.state = "on";
}
else {
trg.state = "off";
}
isOn = !isOn;
}
}
【问题讨论】:
-
是的,缓存系统/gs 吸收了 QML。
标签: image qt memory qml qt-quick