Mesh.coordinates might lead to memory leakage in Python interface

Bug #982854 reported by Johan Hake on 2012-04-16
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
DOLFIN
Undecided
Johan Hake

Bug Description

When returning the coordinates from a Mesh in the Python interface a reference to the Mesh is stored kept in the NumPy array, keeping the Mesh in scope as long as the coordinate array lives. This might lead to memory leakage as the Mesh contains much larger memory structures than the coordinate vector.

In discussion of:

  https://bugs.launchpad.net/dolfin/+bug/966553

a solution was scetched, where the coordinates are stored as a shared_ptr<std::vector<double> >. Then we implement a shared_ptr version of Mesh::coordinates and store this object to the NumPy array instead.

Johan Hake (johan-hake) on 2012-04-16
Changed in dolfin:
milestone: none → trunk
assignee: nobody → Johan Hake (johan-hake)

Is it really memory leakage? The memory will be freed when the array
goes out of scope.

--
Anders

On Mon, Apr 16, 2012 at 08:02:57AM -0000, Johan Hake wrote:
> Public bug reported:
>
> When returning the coordinates from a Mesh in the Python interface a
> reference to the Mesh is stored kept in the NumPy array, keeping the
> Mesh in scope as long as the coordinate array lives. This might lead to
> memory leakage as the Mesh contains much larger memory structures than
> the coordinate vector.
>
> In discussion of:
>
> https://bugs.launchpad.net/dolfin/+bug/966553
>
> a solution was scetched, where the coordinates are stored as a
> shared_ptr<std::vector<double> >. Then we implement a shared_ptr version
> of Mesh::coordinates and store this object to the NumPy array instead.
>
> ** Affects: dolfin
> Importance: Undecided
> Assignee: Johan Hake (johan-hake)
> Status: New
>
> ** Changed in: dolfin
> Milestone: None => trunk
>
> ** Changed in: dolfin
> Assignee: (unassigned) => Johan Hake (johan-hake)
>

Johan Hake (johan-hake) wrote :

I agree, but I think we agree that it is not optimal. I have changed the title to reflect that actual problem.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers