[Insight-developers] Re: Purify error on Mesh

Luis Ibanez luis.ibanez@kitware.com
Mon, 25 Mar 2002 12:05:39 -0500


Hi,

The Mesh has been modified to take care of
releasing the memory allocated for the Cells.

Cells are no longer deriving from LightObject
because the oveload of a MutexLock at each
smart pointer access. Cells can not be shared
now between different meshes, though the cells
container can be.

As a consequence of this change, now the Mesh
is holding normal pointers to the Cells and becomes
responsible for releasing Cells memory if necessary.
A similar situation arise with BoundaryCells which
derive from the Cells class.

The methods:

ReleaseCellsMemory()
ReleaseBoundariesMemory()

were added to the Mesh. These methods verify
if cells memory has to be release and proced to do it.

For this methods to work properly, the user MUST
call the methods:

SetCellsAllocationMethod()
SetBoundariesAllocationMethod()

at some point while he is inserting Cells and Boundaries
on the Mesh.

Failure to call this method will result in an exception
being thrown from  the Mesh destructor because there
is no way in which the Mesh could guess reponsibly
how the user allocated the memory for cells.

Three cases have been identified:

1) The user allocated cells statically (as a static array
or as static cell by cell instantces)
 In that case the mesh doesn't have to release any memory.
The user has to take care of  not trying to use such a Mesh
outside the scope in which the static cells where defined !

2) The user allocated the cells as a continuous dynamic array.
In this case the Mesh takes the first cell and call  delete []
on it.

3) The user allocated the cells dynamically but one by one.
In this case the Mesh iterates over all the cell pointers and
call "delete" on each one.



A similar procedure is performed for the Boundaries.



   Luis

=========================================

Miller, James V (CRD) wrote:

> Luis,
>
>  
>
> I assume you are going to fix the purify errors that you introduced by 
> removing the SmartPointers
>
> from the Cells and CellBoundaries.
>
>
> *Jim Miller*
> */_____________________________________/*
> /Visualization & Computer Vision
> GE Corporate Research & Development
> Bldg. KW, Room C218B
> P.O. Box 8, Schenectady NY 12301
>
> _millerjv@crd.ge.com <mailto:millerjv@crd.ge.com>_/
> /(518) 387-4005, Dial Comm: 8*833-4005, /
> /Cell: (518) 505-7065, Fax: (518) 387-6981/
>
>
>  
>