|
From: Daniel G. <sp...@ho...> - 2002-07-04 07:19:19
|
Hmm...well you could write a function yourself that kept track of the
memory, or use a global variable.
Very basically, you'd have a global variable for memory allocated, and each
time you did Pointer = new Class you could call the sizeof function with
that object and do sizeof(*Pointer)
Maybe it would look like the following:
#include <iostream>
class Car
{
public:
//...
};
double gVariable; // global variable
int main( int argc, char *argv[] )
{
Car *Pointer = NULL;
Pointer = new Car;
gVariable += ( sizeof(*Pointer) );
//...
std::cout << "The memory allocated in total was " << gVariable;
return 0;
}
What does everyone think?
>From: "Javier Turek" <jav...@ci...>
>Reply-To: "Javier Turek" <jav...@ci...>
>To: "DEVC" <dev...@li...>
>Subject: [Dev-C++] Memory
>Date: Thu, 4 Jul 2002 01:53:31 -0300
>
>Hello!
>Does somebody know of a library to use with dev-c++
>to control what is going on with the memory?
>I mean that I want to know how much memory
>I use for my variables and pointers, and at the end
>of my program I must know if all the memory I asked for,
>has been freed.
>
>Thanks.
>Javier
>from Argentina
>
_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com
|