Query Free Memory

Started by
2 comments, last by fpuig 20 years, 10 months ago
Hi I need to know if any function in my program is leaking memory. To know that I need a function that show me how much memory my program use or how much memory is free on the system. Had any of you heard about any? Cheers fpuig
God is Real unless is declared Integer
Advertisement
Override the new and delete which has access to a global variable, which you increment or decrement each time you delete or create something. And before your program exits write the number of objects left that wasnt deleted to a file.

edit: heh, I wrote as I thought, and that wasnt such a good idea.

[edited by - angry on June 18, 2003 4:00:49 PM]
If you are programming for Windows, have a look at GlobalMemoryStatus(). You might also find the CRT debug routines useful.
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
I test GlobalMemoryStatus, GetProcessMemoryInfo and Debug directives. Those functions only report memory changes when a block of more than 5600 bytes is reserved. If I just make a couple of news like:

cVector3f* pVector1 = new cVector3f;
cVector3f* pVector2 = new cVector3f;
cVector3f* pVector3 = new cVector3f;

After that calls, it''s supposed that I had reserve 9*sizeof(float) = 36 bytes. But if I check the memory before and after they report the same physical memory (I print the memory in bytes not in Kb)

Is there a way to do a high accurancy measure of the memory? Or Did I miss something?

Cheers
fpuig
God is Real unless is declared Integer

This topic is closed to new replies.

Advertisement