Mesh.coordinates might lead to memory leakage in Python interface

Bug #982854 reported by Johan Hake
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
DOLFIN
New
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)
Changed in dolfin:
milestone: none → trunk
assignee: nobody → Johan Hake (johan-hake)
Revision history for this message
Anders Logg (logg) wrote : Re: [Bug 982854] [NEW] Mesh.coordinates might lead to memory leakage in Python interface

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)
>

Revision history for this message
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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.