[SciPy-user] Memory Leak in Scipy.Signal.lfilter?

Richard Lyon rchrdlyon1@gmail....
Thu Apr 2 03:02:04 CDT 2009


Hi,

Problem:
=======

Been successfully using scipy to simulate a signal decoding algorithm. 
Recently upgraded from release 0.6.0 to release 0.7.0 and discovered the 
simulation leaks memory, which brings the computer to a grinding halt 
after a few minutes.


Details:
=======

   Microsoft Vista
   Python 2.5.2
   Numpy 1.2.1
   Scipy 0.7.0

The following code leaks memory:

---------------------------------------------------------
# Check if scipy.signal.lfilter causes memory leak
import numpy
from scipy.signal import lfilter

def main():
   # low pass filter coefficients (maybe this should be an array)
   hlp = [-2.145760E-003, -4.058501E-003, -4.629715E-003,
          -1.294677E-003, 6.771358E-003, 1.692096E-002,
          2.300385E-002, 1.825164E-002, 1.908418E-004,
          -2.526333E-002, -4.382636E-002, -3.841010E-002,
          1.735187E-003, 7.313454E-002, 1.565082E-001,
          2.235226E-001, 2.491718E-001, 2.235226E-001,
          1.565082E-001, 7.313454E-002, 1.735187E-003,
          -3.841010E-002, -4.382636E-002, -2.526333E-002,
          1.908418E-004, 1.825164E-002, 2.300385E-002,
          1.692096E-002, 6.771358E-003, -1.294677E-003,
          -4.629715E-003, -4.058501E-003, -2.145760E-003]
   # initialise low pass filter registers (maybe this should be an array)
   lp_filter_registers = [0.0]*(len(hlp)-1)
   # read individual samples and filter
   s = 0
   while s < 1000000:
       # for test just use zero value
       incoming_sample = numpy.array([0.0]);
       # low pass filter samples
       (lp_filtered_sample, lp_filter_registers) = lfilter(hlp, 1.0, 
incoming_sample, -1, lp_filter_registers)
       s = s + 1
      # main entry point
if __name__ == '__main__':
   print 'Running memory leak test'
   main()
   print 'Finished.'
---------------------------------------------------------

When I view the Physical Memory Usage History in the Windows task 
manager it is ramp which only halts growing when memory is exhausted.
For the time being I have reverted back to the previous version of scipy 
to keep working.

Anyone else observed the same problem?

Regards ...



More information about the SciPy-user mailing list