Memory is Leaking but Heob don't get it?
-
I'm with the following problem, in my application I have some "widgets", like small windows inside the main application, that contains multiple QWidgets, for example I have a Histogram Widget with a lot of others widgets inside it. This histogram widget has its own custom .dll
The problem is: If I create one Histogram Widget my RAM gets consumed around 10 MB, and if I close the Histogram I just get 1 MB back , but heob says that from this dll only 65KB "leaked"(I filtered all calls of heob that contains this dll in the stack) .
The other problem is that if I close this Histogram Widget and open another, I don't use 10 MB, I use like 1MB. I'm just lost and would like some light, thans in advance
-
You are checking RAM use with some system tool like System Monitor right?
Then this is perfectly normal. Such tools report RAM reserved for the application. So, when you open your histogram, 10 MB is requested and granted from the Operating System. When you close (delete) the widget it is properly deallocated but the Operating System will typically keep it "reserved" for the application. So the next time your app requests 0-10MB, the memory is already prepared and can be initialized immediately. The OS manages this reservation automatically and it's not under control of your application. But you can be sure it's not a big 10MB memory leak.
So, if heob, valgrind or asan do not detect a big leak, there is no big leak. Do not worry about what system monitor shows.
-
@leonardoMB What exactly would you like @sierdzio to do about this?
-
@leonardoMB said in Memory is Leaking but Heob don't get it?:
@sierdzio Great answer, but what if RAM is a limitation for me? like: I really need that 10 MB
Your OS should give this memory to other processes if necessary and if your process does not use it for some time. Systems are clever about this :-)
-
@leonardoMB said in Memory is Leaking but Heob don't get it?:
Great answer, but what if RAM is a limitation for me? like: I really need that 10 MB
If this is really your problem, then you need to provide more information. More specifically we need your platform and operating system (my guess is embedded with a Linux system?). However, you might get better answers for these kind of problems on Stack Overflow as this is not really related to Qt anymore.