[Insight-users] `Image Memory Management
David Holmes
holmesd3@yahoo.com
Tue, 10 Dec 2002 20:48:02 -0800 (PST)
--- Luis Ibanez <luis.ibanez@kitware.com> wrote:
>
> Hi David,
>
> Well, the fact that the Data is available only
> in the scope of the ImportImageContainer is actually
> an advantage since it will take care of memory
> release.
>
> If what you want is to use this pixel data in
> another
> image, you may want to instantiate another image and
> use the SetPixelContainer() method like:
>
> newimage->SetPixelContainer( pixelContainer );
>
> The memory will be available as long as the
> pixelContainter SmartPointer or the newimage
> SmartPointer exist.
>
>
> The flag that controls memory release in the
> ImportImageContainer is :
>
> bool m_ContainerManageMemory;
>
> and it is set internally by the container.
>
> We could consider adding a public Set() method to
> the
> class API so you could put set the flag to off, then
> let die the container and keep the memory...
>
> This may probably make sense if you are exporting
> the
> data to another library where you don't whant to
> manage
> ITK objects anymore.
>
> Is that the case ?
>
> Please let us know,
>
>
> Thanks
>
>
> Luis
>
>
> =====================================
>
> David Holmes wrote:
>
> > Luis-
> >
> > thank you for your quick response. I was actually
> > looking into the ImportImageContainer when I
> received
> > your note. I implemented your suggestions, but I
> > think that I still have a problem. Now the data
> is
> > limited to the scope of the ImportImageContainer
> > Pointer. Because I am simply grabbing the
> container
> > out of the Image, the flag that controls memory
> > management has already been set to TRUE
> (presumably by
> > the filter object), so the data will still be
> > destroyed outside the scope of the
> > ImportImageContainer Pointer. As such, when I try
> and
> > access the array (by way of the pointer to the
> data
> > outside the function), it core dumps. I've tried
> to
> > find a way to reset that flag, but haven't found
> it
> > yet.
> >
> > does this make sense?
> >
> > I don't know, but if you can help me, I'd
> appreciate
> > it.
> >
> > Thanks
> >
> > david
> >
> >
> >
>
>
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com