Important: Please read the Qt Code of Conduct -

Measure the overall memory usage of my application

  • Greetings.

    I want to measure the overall memory usage of my application Qt (including memory that is not created dynamically, eg, with 'new' operator ). I wonder if there is a class or object in Qt for this type of task.

    In the case of memory created dynamically, I was thinking to create two macro: one to use instead of the new operator and the other instead of delete operator, so keep track memory allocated and freed ... is this a good idea?, is there a better or simpler way to do this measurement?.

    How could I measure the memory is not created dynamically?

    Thanks in advance for any help and/or suggestions.

  • Replacing "new" and "delete" via macro doesn't work, since it only effects your own code - but most memory allocations will probably occur indirectly inside Qt classes and other libraries that you use (not to forget the Standard C library). Instead you would need to "hook": malloc() and free().

    See also:
    "Memory Allocation Hooks":


    Anyway, if you just want to see the overall memory usage of your application, a standard task manager like "htop" on Linux or "Process Explorer" on Windows will do the job! And if you want a more detailed analysis, e.g. to scan for memory leaks, use a tool like "Valgrind" (Linux) or "VLD" (Windows).

Log in to reply