memory leak in basemap 0.98?

Mike Bauer wrote:


Using Python 2.6 results in the following Deprecation Warnings:

/usr/local/lib/python2.6/site-packages/pytz/ DeprecationWarning: the sets module is deprecated
  from sets import Set
/usr/local/lib/python2.6/site-packages/httplib2/ DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import md5
/usr/local/lib/python2.6/site-packages/httplib2/ DeprecationWarning: the sha module is deprecated; use the hashlib module instead
  import sha

Don't know if this is a problem.

Mike: No, that's not a problem. I've fixed the httplib2 warnings in SVN.

I moved the basemap instance call outside the loop and the problem is greatly reduced; although my memory usage still linearly increases but by say 0.5 Gb instead of 6 Gb.
I can live with that. Python2.5 lacks this increase as you expected.

I ran trunk/matplotlib/unit// with python2.6:
      Average memory consumed per loop: 0.4428k bytes

/Same call from python2.5:
    Average memory consumed per loop: 0.5672k bytes

Seems basemap is needed to the memory leak.


Can you send me the script you used to detect the leak?



On Tue, Oct 21, 2008 at 5:36 PM, Jeff Whitaker <jswhit@…146… > <mailto:jswhit@…146…>> wrote:

    Mike Bauer wrote:

        I've been testing matplotlib and basemap (0.98.x and 0.99.x
        via svn source) and python 2.6 (via svn) on ubuntu 8.04 (AMD-64).

        I noticed that calling basemap in a loop results in a fairly
        steep linear increase in memory use; I burn though 6 Gb in a

        Putting a loop in from the provided examples does
        this as well, so I don't think it's something I'm doing.

        Any ideas?



        P.S. Note that I'd like to use python 2.6 for the
        multiprocessing module (not in use in this script as of yet).
        My base install of python 2.5 with matplotlib and basemap
        (0.98.3 and 0.99.1 via sourceforge sourse) works fine.

    Mike: Note that you don't actually need to recreate the basemap
    instance each time through the loop (since the map projection
    region is not changing).
    AFAIK there are no serious memory leaks in basemap with python 2.5
    - so if you can provide an example that triggers one I'd like to
    see it.
    Sounds like it might only be occurring with python 2.6?


    – Jeffrey S. Whitaker Phone : (303)497-6313
    Meteorologist FAX : (303)497-6449
    NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@…259…
    325 Broadway Office : Skaggs Research Cntr 1D-113
    Boulder, CO, USA 80303-3328 Web :

Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web :