Memory Usage after object.destroy
-
Hi
I created object dynamically in QML. When object is created memory usage increases. When I object is deleted using object.destroy, I don't see memory usage is getting decreased.
- Memory usage remains the same as before delete. Any idea why ?
Tried this on MAC with Qt 5.5. and 5.7. Same result.
-
@Mowlee , @dheerendra
How are you two measuring the "memory usage" here?If you are using some tool which shows the overall memory usage of your process, be aware that it is extremely likely that freed memory from an application will remain in its memory allocation awaiting re-use in future allocations. For example, if it ultimately uses something like
malloc()
to get its memory that maintains its own table of blocks in use & blocks no longer used but available for re-use. To "hand memory back to the OS" requires calling something likebrk()
, and that only works if the memory to be returned is at the top of the allocated area; I would doubt Qt will call this.So if you really want to know how much memory is actually in use/free for reallocation you will need to use a dedicated tool to walk the heap/handles within the process, not just
ps
ortaskman
. -
@JonB
Thank you for reply.I didnt use any tool for memory usage. But my issue looks similar to @dheerendra 's issue.
- I have created a object.
- At this time children length of object is 1 [object.parent.children.length]
- Destroyed that and created another object.
- At this point, the children length of the object is 2[object.parent.children.length]
After destroying the object(object.destroy()), do we need to use any other call to clear memory?
Regards
Mowlee