Print The Current Memory Usage
·
354 words
·
2 minutes read
The program below is designed to print out the current state of how much memory is being used, how much has been used and how much the system has reserved. You only really need the PrintMemUsage()
function to do this, the rest of the main()
is there to illustrate it working (with a gif showing this at the end of this post).
The most important figure if often the Alloc
which is the amount allocated heap objects. Our example also illustrates that the Alloc
memory is not reduced necessarily when a variable is cleared, but when the garbage collector runs.
|
|
Example: