|
From: Daniel G. <sp...@ho...> - 2002-07-04 12:37:08
|
Ok I'm a little lost...
you can't destroy classes, only instances of classes (objects). If you
destroy the object the memory is released - I assume by "losing memory" you
mean memory is not deallocated i.e. made available.
does anyone know if it is possible to allocate X memory for an application
and only let it use that much? I'm thinking that X MB of memory could be
allocated then at the end of the program check to see if it is all available
again.
like if ( CurrentMem == InitialMem )
{
cout << "Memory has been managed perfectly.";
}
>Thank you.
>I will try to explain myself better.
>I have to make some classes for the univesity
>and the profesor told me that my program
>doesn't has to lose memory. For example:
>I've got an structure that uses a list of nodes.
>If I destroy the class, maybe, I'll need to
>destroy all nodes. I need to verify that
>I'm not loosing memory (asking for it and don't
>release it) at the end of the program.
>I know there are modules which you can use
>for these things.
>
>Thanks again,
>Javier
>
>----- Original Message -----
>From: "Daniel Glenfield" <sp...@ho...>
>To: <jav...@ci...>; <dev...@li...>
>Sent: Thursday, July 04, 2002 4:18 AM
>Subject: Re: [Dev-C++] Memory
>
>
> > 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
|