From eeda4ac4d2d1b194325eb70b5eb1e55a92ecf779 Mon Sep 17 00:00:00 2001 From: Tomi Korpipaa Date: Tue, 27 Feb 2024 14:07:34 +0200 Subject: [PATCH] Reduce the amount of leaked memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds calling releaseResources() to the QQuickWindow each time series visuals change. It appears some resources are not released even though deleteLater() has been called for them. The patch drops the memory consumption increase significantly (3.75-fold in the test app from the ticket when in Legacy mode). Some memory consumption increase is still observed, so the ticket should not be closed. However, priority can be dropped a bit. Task-number: QTBUG-113199 Pick-to: 6.6 Change-Id: I79582e64c52c001d43550ed2f8f67bcaec0c42fc Reviewed-by: Sami Varanka Reviewed-by: Sakaria Pouke Reviewed-by: Tomi Korpipää Reviewed-by: Dilek Akcay (cherry picked from commit f83d157fd541350dd4e06e7fac195363f103db0e) Reviewed-by: Qt Cherry-pick Bot --- src/graphs3d/qml/qquickgraphsbars.cpp | 3 +++ src/graphs3d/qml/qquickgraphsscatter.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/graphs3d/qml/qquickgraphsbars.cpp b/src/graphs3d/qml/qquickgraphsbars.cpp index 8afd1f81..d08cadc3 100644 --- a/src/graphs3d/qml/qquickgraphsbars.cpp +++ b/src/graphs3d/qml/qquickgraphsbars.cpp @@ -1508,6 +1508,9 @@ void QQuickGraphsBars::updateBarVisuals(QBar3DSeries *series) QLinearGradient gradient = series->baseGradient(); if (optimizationHint() == QAbstract3DGraph::OptimizationHint::Legacy) { + // Release resources that might not have been deleted even though deleteLater had been set + window()->releaseResources(); + for (int i = 0; i < barList.count(); i++) { QQuick3DModel *model = barList.at(i)->model; auto textureData = static_cast( diff --git a/src/graphs3d/qml/qquickgraphsscatter.cpp b/src/graphs3d/qml/qquickgraphsscatter.cpp index 7c5c290a..d3d5c405 100644 --- a/src/graphs3d/qml/qquickgraphsscatter.cpp +++ b/src/graphs3d/qml/qquickgraphsscatter.cpp @@ -269,6 +269,9 @@ void QQuickGraphsScatter::updateScatterGraphItemVisuals(ScatterModel *graphModel : false; if (optimizationHint() == QAbstract3DGraph::OptimizationHint::Legacy) { + // Release resources that might not have been deleted even though deleteLater had been set + window()->releaseResources(); + if (itemCount != graphModel->dataItems.size()) qWarning() << __func__ << "Item count differs from itemList count";