It is either a bug of the debugger, or the compiler inlines the function =
in
main() (in a bad way), but i believe it is the first. Consider the code:=0D
=0D
#include <list>=0D
#include <iostream>=0D
#include <cstdlib>=0D
=0D
class something=0D
{=0D
public:=0D
~something() { std::cout<<"Hesperia\n"; }=0D
};=0D
=0D
void f()=0D
{=0D
using std::list;=0D
=0D
list<something> ls(10);=0D
}=0D
=0D
=0D
int main()=0D
{=0D
f();=0D
=0D
std::system("pause");=0D
=0D
}=0D
=0D
=0D
It produces:=0D
=0D
C:\c>temp=0D
Hesperia=0D
Hesperia=0D
Hesperia=0D
Hesperia=0D
Hesperia=0D
Hesperia=0D
Hesperia=0D
Hesperia=0D
Hesperia=0D
Hesperia=0D
Hesperia=0D
Press any key to continue . . .=0D
=0D
=0D
The code:=0D
=0D
#include <list>=0D
#include <iostream>=0D
#include <cstdlib>=0D
=0D
class something=0D
{=0D
public:=0D
~something() { std::cout<<"Hesperia\n"; }=0D
};=0D
=0D
inline void f()=0D
{=0D
using std::list;=0D
=0D
list<something> ls(10);=0D
}=0D
=0D
=0D
int main()=0D
{=0D
f();=0D
=0D
std::system("pause");=0D
=0D
}=0D
=0D
=0D
also produces:=0D
=0D
C:\c>temp=0D
Hesperia=0D
Hesperia=0D
Hesperia=0D
Hesperia=0D
Hesperia=0D
Hesperia=0D
Hesperia=0D
Hesperia=0D
Hesperia=0D
Hesperia=0D
Hesperia=0D
Press any key to continue . . .=0D
=0D
=0D
=0D
Ioannis Vranos=0D
=0D
* Programming pages: http://www.noicys.freeurl.com=0D
* Alternative URL: http://run.to/noicys =0D
=0D
-------Original Message-------=0D
=0D
From: Pablo=0D
Date: =D0=DD=EC=F0=F4=E7, 20 =D6=E5=E2=F1=EF=F5=DC=F1=E9=EF=F2 2003 3:53:=
20 =EC=EC=0D
To: dev...@li...; no...@ho...=0D
Subject: Re: Re: memory allocation with STL list=0D
=0D
Thank you for your answer.=0D
For the memory, I just put a breakpoint before the execution of f() and n=
ote
the total allocated memory. Then, at the "pause" prompt, I measure the to=
tal
memory again and I substract the two quantities. ( with the example I get
~16.4Mb)=0D
For the compiler, I use the standard compiler included in Dev C++, have y=
ou
tested other compilers under Dev?=0D
Pablo Arbelaez=0D
=20 |