echonest/remix — pull request #10 by psobot (2012-10-31 21:06:02+00:00)
Title: Fixed memory leak in pydirac

I think I've found a pretty substantial memory leak in `pydirac` - a temporary array being alloc'd doesn't get `Py_DECREF`'d, which causes Python to hold onto the reference forever, essentially leaking the entire temporary buffer. (As `pydirac` is usually used on very large arrays... this leads to many-dozens-of-megabytes being lost every call.)

Memory usage without this patch:
![Increasing forever!](http://petersobot.com/pydirac_issue/old.png "Increasing forever!")

...and *with* the patch:
![Constant!](http://petersobot.com/pydirac_issue/new.png "Constant!")

---
Test program to generate the above Instruments graphs:

import audio
import dirac

a = audio.LocalAudioFile('../wubmachine/tests/mario.mp3')
for _ in xrange(0, 1000):
dirac.timeScale(a[0:300000].data, 1.4, 44100, 0)