Skip to content

Fixed memory leak in pydirac #10

Merged
merged 2 commits into from Nov 1, 2012

3 participants

@psobot
psobot commented Oct 31, 2012

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!

...and with the patch:
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)
@psobot psobot Fixed memory leak in dirac
Temporary view of `insound` wasn't being DECREF'd, so it hung around
and never got cleaned up by the Python GC.
26c84f5
@bwhitman
The Echo Nest member
@psobot
psobot commented Nov 1, 2012

Found a leak in echonest.action.Crossfade too:

Pre-patch:
Old

...and post-patch:
New


Test case to reproduce the above graphs:

import echonest.audio
import echonest.action

a = echonest.audio.LocalAudioFile('../wubmachine/tests/mario.mp3')
for _ in xrange(0, 100000):
    echonest.action.Crossfade([a, a], [5, 10], 5).render()
@tjehan
The Echo Nest member
tjehan commented Nov 1, 2012

Awesome peter! These would be mine... oops!

@bwhitman bwhitman merged commit 31c3739 into echonest:master Nov 1, 2012
@bwhitman
The Echo Nest member
bwhitman commented Nov 1, 2012

thanks peter!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.