[Insight-developers] List of smart pointers

Miller, James V (Research) millerjv@crd.ge.com
Mon, 4 Nov 2002 11:56:31 -0500


STL likes to "cache" memory, particularly in the list class.
So if you have a list or "foo"'s, and call list.clear(), the
destructors of the "foo"'s will be called.  But the block of 
memory for the "foo" will be kept available under the assumption
that later on you are going to add something to the list that 
is the size of a "foo".  When the list is destructed, I think
these blocks of memory are returned to the free list.

So the bulk data should have been destroyed when you called
list.clear() but the sizeof(SmartPointer) blocks would probably
not have been returned to the system free pool.

Jim

> -----Original Message-----
> From: Julien Jomier [mailto:jjomier@cs.unc.edu]
> Sent: Friday, November 01, 2002 10:49 AM
> To: 'William A. Hoffman'; 'Insight Developers'
> Subject: RE: [Insight-developers] List of smart pointers
> 
> 
> Well, I noticed that the memory was not totally freed.
> That's why I was suspicious but maybe, like you said,
> it is due to the list class itself.
> 
> Thanks for the clarification.
> 
> Julien
> 
> > -----Original Message-----
> > From: insight-developers-admin@public.kitware.com 
> > [mailto:insight-developers-admin@public.kitware.com] On 
> > Behalf Of William A. Hoffman
> > Sent: Friday, November 01, 2002 8:41 AM
> > To: Julien Jomier; Insight Developers
> > Subject: Re: [Insight-developers] List of smart pointers
> > 
> > 
> > list.clear should call the destructor on all the smart 
> pointers which 
> > should free
> > the itk objects.   The memory may be kept by the list class 
> > memory pool, but
> > that should not be a problem.    What is the problem you are having?
> > 
> > -Bill
> > 
> > 
> > At 10:58 PM 10/30/2002 -0500, Julien Jomier wrote:
> > >Hi all,
> > >
> > >I have a problem deleting a list of smart pointers.
> > >When I do a "list.clear()" it seems that the header of
> > >the smart pointer is still in memory, isn't it ?
> > >
> > >Is there a way to delete completly the list?
> > >Should I use a list of raw pointers instead ?
> > >
> > >Thanks
> > >
> > >Julien
> > >
> > >_______________________________________________
> > >Insight-developers mailing list 
> Insight-developers@public.kitware.com
> > >http://public.kitware.com/mailman/listinfo/insight-developers
> > 
> > 
> > 
> > _______________________________________________
> > Insight-developers mailing list
> > Insight-developers@public.kitware.com
> > http://public.kitware.com/mailman/listinfo/insight-developers
> > 
> 
> _______________________________________________
> Insight-developers mailing list
> Insight-developers@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-developers
>