ObsPy SeedLink client memory leak and the fix

Buenos días!

(Ubuntu 12.04 x64, native Python 2.7.3 x64, ObsPy 0.9.2)

When used in a long running program, ObsPy SeedLink client seems to leak memory. The leak
can be discovered with the low level tools like the ‘resource’ module:

import resource

somewhere in the SLClient callback…

print resource.getrusage(resource.RUSAGE_SELF).ru_maxrss

For long running tasks, this displays ever increasing amount of memory used. While high-level
tools reporting the number of newly created Python objects like ObjGraph display nothing.

We believe the leak is due to the range() operator used in obspy/client/slstate.py, line 202.
We now use a patched version of the SeedLink client which employs xrange() function instead
of the range() operator. This seems to fix the leak.

Happy Obspy-ing,

Hi Branden,

thanks for the report.

This is really strange - I don’t see how replacing range() by xrange() can change anything as no reference to is kept anywhere. In any case; if that fixes it, it should also be fixed in the latest ObsPy master where all instances of range() or patched to xrange() on Python 2.x by virtue of the “future” package.

We’ll hopefully release a new ObsPy version in the next couple of days so an update should fix your issue. Let us know if it persists.