[SciPy-user] Memory leak in delaunay interpolator

Robert Kern robert.kern at gmail.com
Thu Jan 17 01:10:35 EST 2008


Michael.Abshoff wrote:
> Pauli Virtanen wrote:
>> Wed, 16 Jan 2008 20:40:33 +0100, Nils Wagner wrote:
>>
>>> On Wed, 16 Jan 2008 11:38:02 +0100
>>>   Rob Hetland <hetland at tamu.edu> wrote:
>>>> I'm not sure who else uses the delaunay package (was in
>>>>
>>>> scipy.sandbox, now lives in scikits), but I find it
>>>> indispensable. Today I found what appears to be a memory leak in the
>>>> interpolator and extrapolator objects.  This simple code demonstrates
>>>> the leak:
>> This may be the same as bug #382 (patch is available in the ticket).
>>
>> Also #376 may be relevant for the observed segfault: there are
>> (or were?) known crasher bugs in the delaunay module.
>>
> 
> Hi,
> 
> I ran the following code in Sage under valgrind's memcheck [slightly 
> adapted from the previous post]:
> 
> sage: from delaunay import *
> sage: from numpy.random import rand
> sage: xi, yi = rand(2, 1000)
> sage: tri=Triangulation(xi, yi)
> sage: for n in range(100000):
> ....:         interp = tri.nn_interpolator(rand(1000))
> ....:     z = interp(x, y)
> 
> using today's scipy sandbox checkout. The following popped up:

That's no longer valid. It lives here now:

   http://svn.scipy.org/svn/scikits/trunk/delaunay/

> ==16816== 6,944 bytes in 1 blocks are definitely lost in loss record 
> 7,840 of 8,087
> ==16816==    at 0x4A1BB35: malloc (vg_replace_malloc.c:207)
> ==16816==    by 0x1BFE7829: VoronoiDiagramGenerator::myalloc(unsigned) 
> (VoronoiDiagramGenerator.cpp:725)
> ==16816==    by 0x1BFE788D: VoronoiDiagramGenerator::PQinitialize() 
> (VoronoiDiagramGenerator.cpp:570)
> ==16816==    by 0x1BFE8305: VoronoiDiagramGenerator::voronoi(int) 
> (VoronoiDiagramGenerator.cpp:924)

This is not terribly surprising. There are about 4 different memory managers 
involved here: malloc, Stephan Fortune's, C++'s, and Python's.

> ==16816==    by 0x1BFE89DA: 
> VoronoiDiagramGenerator::generateVoronoi(double*, double*, int, double, 
> double, double, double,
> double) (VoronoiDiagramGenerator.cpp:136)
> ==16816==    by 0x1BFE65D7: delaunay_method (_delaunay.cpp:125)
> ==16816==    by 0x4833C1: PyEval_EvalFrameEx (ceval.c:3564)
> ==16816==    by 0x4852CA: PyEval_EvalCodeEx (ceval.c:2831)
> ==16816==    by 0x4CE817: function_call (funcobject.c:517)
> ==16816==    by 0x415542: PyObject_Call (abstract.c:1860)
> ==16816==    by 0x41BC62: instancemethod_call (classobject.c:2497)
> ==16816==    by 0x415542: PyObject_Call (abstract.c:1860)
> 
> I am not sure if the patch from #382 has been applied to svn trunk, I am 
> still finding my way around scipy.

It got applied in the scikits tree, where it now lives.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco



More information about the SciPy-User mailing list