separation function is a memory hog

Bug #664479 reported by Enno Middelberg
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PyEphem
Fix Released
High
Brandon Rhodes

Bug Description

The function that calculates the separation of bodies (either in RA and Dec or in Az/El) consumes a lot of memory when called repeatedly. The following code grabs 1.5GB of RAM in a few seconds:

import ephem as e
centre=e.readdb("centre,f|M|F7,10:00:00, 50:00:30.0,2.02,2000")
target=e.readdb("test,f|M|F7,10:00:00, 50:00:00.0,2.02,2000")
centre.compute()
target.compute()

for x in range(1e7):
   sep=e.separation([centre.ra, centre.dec], [target.ra, target.dec])

If this isn't a bug then I'd like to know how I can call the separation function many times without it grabbing so much RAM.

Regards,

Enno

Revision history for this message
Brandon Rhodes (brandon-rhodes) wrote :

Enno, thank you very much for reporting this! And sorry for any trouble that this bug caused you; I'll buy you a beer if we ever wind up at a conference together. :-)

There was indeed a memory leak in separation() in the specific case that it is given coordinate sequences instead of bodies or observers. I have pushed a fix to the PyEphem Bitbucket repository, and will be releasing a new PyEphem version this weekend with the fix. Here is the changeset in the repository in case you want to try the new version before I do the release:

http://bitbucket.org/brandon/pyephem/changeset/95bf603370e7

Let me know if you have any further problems!

Changed in pyephem:
status: New → Fix Committed
importance: Undecided → High
assignee: nobody → Brandon Craig Rhodes (brandon-rhodes)
Changed in pyephem:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.