nipy/dipy — pull request #411 by MarcCote (2014-08-27 17:36:54+00:00)
Title: Fix memory leak in cython functions length and set_number_of_points

I found a memory leak in the cythonized version of `dipy.tracking.streamline.length` and `dipy.tracking.streamline.set_number_of_points`. Cython automatically convert a list of numpy arrays into a vector of memoryviews but at the end of the function, when clearing the vector, memviews' refcount are not decreased. So, I do it manually.

I added a new unit test to expose the memory leak: `test_streamline:TestStreamline.test_memory_leak()`. Below, I report the difference in RAM usage between successive calls to each function.

**Before**
`length()`
['0.13Mo', '0.22Mo', '0.28Mo', '0.50Mo', '0.31Mo', '0.33Mo', '0.08Mo', '0.41Mo', '0.14Mo', '0.06Mo', '0.47Mo', '0.31Mo', '0.32Mo', '0.17Mo', '0.48Mo', '0.29Mo', '0.06Mo', '0.13Mo', '0.20Mo']

`set_number_of_points()`
['1.50Mo', '0.90Mo', '1.26Mo', '1.11Mo', '1.89Mo', '1.06Mo', '1.02Mo', '1.09Mo', '1.12Mo', '1.17Mo', '1.12Mo', '1.12Mo', '1.12Mo', '1.12Mo', '1.12Mo', '1.12Mo', '1.12Mo', '0.98Mo', '1.09Mo']

**Now**
`length()`
['0.15Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo']

`set_number_of_points()`
['0.06Mo', '0.17Mo', '0.00Mo', '0.25Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo', '0.00Mo']