2

I think I may have misunderstood something here... But here goes.

I'm using the psd method in matplotlib inside a loop, I'm not making it plot anything, I just want the numerical result, so:

import pylab as pyl
...
psdResults = pyl.psd(inputData, NFFT=512, Fs=sampleRate, window=blackman)

But that's being looped 36 times every time I run the function it's in.

I'm getting a slow memory leak when I run my program over time, so used 'heapy' to monitor this, and every time I run the function, it adds 36 to these 3 heaps:

dict matplotlib.line.Line26
dict matplotlib.transforms.CompositeAffine2D
dict matplotlib.path.Path

I can only conclude that each time I use the psd method it merely adds it to some dictionary somewhere, whereas I want to effectively wipe the memory - i.e. reset pylab each loop so it doesn't store anything.

I could be misinterpreting heapy but it seems pretty clear that pylab is just growing each loop even though I only want to use it's psd method, I don't want it saving the results anywhere itself !

Cheers

1 Answer 1

3

Try this:

from matplotlib import mlab
psdResults = mlab.psd(inputData, NFFT=512, Fs=sampleRate, window=blackman)

Does that improve the situation?

Sign up to request clarification or add additional context in comments.

3 Comments

Excellent, yes it has... That has also highlighted the difference in import types too. Thanks alot! Just got to fix the other memory leaks now..!
In fact that's actually fixed all of them. Awesome.
Wow, great! If you use ipython, the command pylab.psd?? will show you the source code. From there, I traced psd back to Axes and then mlab. This is how ipython introspection can help determine what is really going on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.