Diego Martins wrote:
Hi all! I am doing a crude investigation of memory leaks in objects
created by external libraries.
Welcome to the club!
Since I don't have access to the source code, I can't tell if an
object are freeing its resources properly during destruction.
For now, I need a portable function that can tell me the available
free store memory.
There is no such standard function. You either need to write your own,
or use whatever mechanism your OS provides.
With that, I can do things like:
size_t mem = getFreeStoreAvailable();
{
SuspiciousObject obj;
...
} // obj destructor invoked here by compiler
assert( mem == getFreeStoreAvailable() );
of course it won't work for detecting resource leaks (e.g: handles)
No such thing[s] in standard C++.
>
do you know this function? any ideas?
No such standard function. Try the newsgroup for your OS.
Generally speaking, you _could_ measure it by allocating [in a loop]
different amounts until you get a failure, followed by freeing all that
you just allocated. However, that is not necessarily the true measure
of the "available free store memory". Remember the "you change it if
you measure it" principle? Ultimately, even if you have to call some
function to measure the free store memory, you *could* change it, and
the behaviour of the program *might* be different from if you didn't
ask for the avaiable free store memory.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask