FastMM: Total Allocated Memory

后端 未结 4 2003
刺人心
刺人心 2021-01-05 17:47

How could I get the total amount of memory, that allocated by FastMM?

I\'ve tried that:

function GetTotalAllocatedMemory: Cardinal;
var
  MMState: TM         


        
4条回答
  •  梦毁少年i
    2021-01-05 18:09

    I also have faced this situation:

    Anyways it returns something strange. It 5 times less than a value which I can see in Windows task manager. I believe that the amount of memory allocated by a Delphi application equals FastMM allocated memory plus some system overhead. Am I wrong?

    and wasted several hours trying to find out where all the memory is. My app occupied 170 Mb according to Task manager but FastMM's stats was showing total size of allocated blocks ~13 Mb:

    12565K Allocated
    160840K Overhead
    7% Efficiency
    

    (excerpt from FastMM LogMemoryManagerStateToFile procedure output). Finally I realized that this enormous overhead is caused by FullDebug mode. It keeps stacktraces for every allocation so if you've many tiny memory blocks allocated (my app had UnicodeString x 99137, Unknown x 17014 and ~10000 of Xml objects) the overhead becomes frightening. Removing FullDebug mode returned memory consumption to its normal values.

    Hope this help somebody.

提交回复
热议问题