Memory not released when multiple Image is loaded continuously
-
Let's maybe take one step back.
a) Memory leak
There is no memory leak.b) Use case
Are we really sure, that all pixmaps / images are really used only once?
Which operating system is used? How about e.g. the XCB backing store? What happens, if a displayed image is covered / uncovered by other screen assets? Do you really wanna re-render in that case?
Why is caching a problem at all?
Do we not have enough memory?Edit:
Sorry, our messages have crossed.
If you want to show a total of 50 different images and have smooth movements, 512MB of RAM is probably too little.
I'd try it out on a host with sufficient RAM and see what's the minimum required memory.
Maybe reducing the images in size and number helps. -
Let's maybe take one step back.
a) Memory leak
There is no memory leak.b) Use case
Are we really sure, that all pixmaps / images are really used only once?
Which operating system is used? How about e.g. the XCB backing store? What happens, if a displayed image is covered / uncovered by other screen assets? Do you really wanna re-render in that case?
Why is caching a problem at all?
Do we not have enough memory?Edit:
Sorry, our messages have crossed.
If you want to show a total of 50 different images and have smooth movements, 512MB of RAM is probably too little.
I'd try it out on a host with sufficient RAM and see what's the minimum required memory.
Maybe reducing the images in size and number helps.@Axel-Spoerl said in Memory not released when multiple Image is loaded continuously:
b) Use case
Are we really sure, that all pixmaps / images are really used only once?we may come across the same image again during the same angle received.
Which operating system is used?
QNX
How about e.g. the XCB backing store? What happens, if a displayed image is covered / uncovered by other screen assets? Do you really wanna re-render in that case?
We are handing the visibleChanged property from QML to stop the animation if it is not on that screen.
Directly we render the exact Image for the current position then when this screen is rendered.Why is caching a problem at all?
Do we not have enough memory?We don't have enough memory.
Edit:
If you want to show a total of 50 different images and have smooth movements, 512MB of RAM is probably too little.
Maybe reducing the images in size and number helps.Reducing the images would not solve the issue, but it postpones it.
-
Need a clean way to not accumulate the memory on every reload of the QML Image
-
One step back again: What's the problem? The cache should resize, if the application runs out of memory. Does your application crash?
-
One step back again: What's the problem? The cache should resize, if the application runs out of memory. Does your application crash?
@Axel-Spoerl said in Memory not released when multiple Image is loaded continuously:
**The cache should resizeI don't see the cache getting resized.
if I run the top command and perform a script to continuously run the angle change,
I get the memory utilized increased - leading to low memory, once the memory reaches below 15MB or so, the System Hangs, and after few seconds application crashes.Even if we come out of that screen during the update, the memory utilisation stops and is never freed.
-
Which Qt version are you using?
-
Which Qt version are you using?
@Axel-Spoerl said in Memory not released when multiple Image is loaded continuously:
Which Qt version are you using?
5.15
-
That explains a lot. Outdated version. There is a memory leak in the quick pixmap cache, and it won't be fixed.
Upgrade to Qt 6.7. -
However, we cannot upgrade to newer Qt versions at this stage of the project.
Is there any other way possible?There should be some workaround to clear the accumulated memory.?
-
Qt 5.15 is an outdated Qt version. Given the simplicity of the project, cannot sound more like don't want to.
There is no other way possible and a workaround for 5.15 will not be implemented. -
There are a few deprecated APIs used and many syntax changes if we upgrade to the latest 6.x version which is risky at this stage.
hence we are finding an alternative way.Any possibility of calling garbage collection periodically?
Will this accumulated memory get freed with garbage collection? -
There are a few deprecated APIs used and many syntax changes if we upgrade to the latest 6.x version which is risky at this stage.
hence we are finding an alternative way.Any possibility of calling garbage collection periodically?
Will this accumulated memory get freed with garbage collection?@AdarshKale said in Memory not released when multiple Image is loaded continuously:
Any possibility of calling garbage collection periodically?
Will this accumulated memory get freed with garbage collection?No. No.
If you read referenced QTBUG you would see how involved the code is, and that it has been integrated into Qt6.x.
-
There are a few deprecated APIs used and many syntax changes if we upgrade to the latest 6.x version which is risky at this stage.
hence we are finding an alternative way.Any possibility of calling garbage collection periodically?
Will this accumulated memory get freed with garbage collection?There are a few deprecated APIs used and many syntax changes if we upgrade to the latest 6.x version which is risky at this stage.
How complex and risky can an opensource wheel rotation app be, when it has to fit into 500MB of RAM including OS and Qt?
hence we are finding an alternative way.
No matter how often you ask: Upgrade to Qt6 is the only option.
-
Qt 5.15 is an outdated Qt version. Given the simplicity of the project, cannot sound more like don't want to.
There is no other way possible and a workaround for 5.15 will not be implemented.@Axel-Spoerl said in Memory not released when multiple Image is loaded continuously:
Qt 5.15 is an outdated Qt version. Given the simplicity of the project, cannot sound more like don't want to.
You've got to chill. Qt 5.15 is still a supported LTS version. Doing a major version upgrade of a big depency like Qt is not a small meaningless task. It's very understandable that this can't been done in an advanced stage of a project.
@AdarshKale as it seems there is no easy fix for your issue in Qt 5, a workaround would be to not use
Image
. What do you mean by wheel rotation? Is that changing the angle or rotating between multiple images? The formzr could be done by animating the rotation property.
Alternatively if you do need to have multiple images, you could try implementing a custom QQuickPaintedItem and painting your images there, bypassing the QtQuick cache. -
Has precreating all of the required Image instances been tried?
I haven't delved into the pixmap cache bug, but the description suggests that it is loading (and unloading) that causes the leak, rather than repeat references to loaded data. Rather than changing the source of a single Image, just set the current image.visible to false, and the next to true.
Another alternative is to attempt to structure the animation as a transformation of a single Image.
-
@Axel-Spoerl said in Memory not released when multiple Image is loaded continuously:
Qt 5.15 is an outdated Qt version. Given the simplicity of the project, cannot sound more like don't want to.
You've got to chill. Qt 5.15 is still a supported LTS version. Doing a major version upgrade of a big depency like Qt is not a small meaningless task. It's very understandable that this can't been done in an advanced stage of a project.
@AdarshKale as it seems there is no easy fix for your issue in Qt 5, a workaround would be to not use
Image
. What do you mean by wheel rotation? Is that changing the angle or rotating between multiple images? The formzr could be done by animating the rotation property.
Alternatively if you do need to have multiple images, you could try implementing a custom QQuickPaintedItem and painting your images there, bypassing the QtQuick cache.@GrecKo
I'll chill, thanks for the feedback!
5.15 releases are either outdated, or commercial.
Hence my reluctance to supporting them through the forum. -
There are a few deprecated APIs used and many syntax changes if we upgrade to the latest 6.x version which is risky at this stage.
How complex and risky can an opensource wheel rotation app be, when it has to fit into 500MB of RAM including OS and Qt?
hence we are finding an alternative way.
No matter how often you ask: Upgrade to Qt6 is the only option.
How complex and risky can an opensource wheel rotation app
Wheel Rotation is just one feature among 100s of them in this project.
We will consider upgrading to the latest Qt versions going further in upcoming projects. -
@Axel-Spoerl said in Memory not released when multiple Image is loaded continuously:
Qt 5.15 is an outdated Qt version. Given the simplicity of the project, cannot sound more like don't want to.
You've got to chill. Qt 5.15 is still a supported LTS version. Doing a major version upgrade of a big depency like Qt is not a small meaningless task. It's very understandable that this can't been done in an advanced stage of a project.
@AdarshKale as it seems there is no easy fix for your issue in Qt 5, a workaround would be to not use
Image
. What do you mean by wheel rotation? Is that changing the angle or rotating between multiple images? The formzr could be done by animating the rotation property.
Alternatively if you do need to have multiple images, you could try implementing a custom QQuickPaintedItem and painting your images there, bypassing the QtQuick cache.What do you mean by wheel rotation? Is that changing the angle or rotating between multiple images? The formzr could be done by animating the rotation property.
Here this is not simple Image rotation, we have an axle with 2 wheels attached to them on both ends and we need to rotate the wheels alone based on the direction.
We will try on the QQuickPaintedItem, Thanks for the input. -
What do you mean by wheel rotation? Is that changing the angle or rotating between multiple images? The formzr could be done by animating the rotation property.
Here this is not simple Image rotation, we have an axle with 2 wheels attached to them on both ends and we need to rotate the wheels alone based on the direction.
We will try on the QQuickPaintedItem, Thanks for the input.@AdarshKale said in Memory not released when multiple Image is loaded continuously:
Here this is not simple Image rotation, we have an axle with 2 wheels attached to them on both ends and we need to rotate the wheels alone based on the direction.
I don't see how that invalidate using a simple
rotation
. But I don't have all the info you have so it might actually be not possible. Are you willing to share an image of how the wheels will appear rotated? Even a quick sketch should do. -
@AdarshKale said in Memory not released when multiple Image is loaded continuously:
Here this is not simple Image rotation, we have an axle with 2 wheels attached to them on both ends and we need to rotate the wheels alone based on the direction.
I don't see how that invalidate using a simple
rotation
. But I don't have all the info you have so it might actually be not possible. Are you willing to share an image of how the wheels will appear rotated? Even a quick sketch should do.@GrecKo said in Memory not released when multiple Image is loaded continuously:
I don't see how that invalidate using a simple
rotation
. But I don't have all the info you have so it might actually be not possible. Are you willing to share an image of how the wheels will appear rotated? Even a quick sketch should do.From centre to right, we have around 25 images and from centre to left, we have 25 images.
We have intermediate angles between the centre and right as well as left.We need to rotate the wheels based on the Actual steering wheel angle.
The wheels are also not like the 2D circular image, they have different perspectives when they are at different angles.