pylab.savefig() causes memory leak in matplotlib-0.91.2

Bug #246239 reported by przemkus
16
Affects Status Importance Assigned to Milestone
matplotlib (Ubuntu)
Fix Released
Undecided
Unassigned
Nominated for Hardy by Benjamin Drung

Bug Description

I am using Ubuntu 8.04 on both i386 and amd64 machines.
At present Ubuntu 8.04 with all available updates has matplotlib in version 0.91.2

The bug appears in particular to python programmers who save to disk many plots with pylab in single python process.
The bug I am mentioning causes serious memory leaks when calling pylab.savefig()
In my case it is about 15 MB of memory leak for each call of savefig() causing entire RAM consumption in the end.

I decided not to put here any screenshots and so on, because this bug is already fixed in matplotlib version 0.91.4 (latest from 0.91 branch)
See the changelog entry:
2008-05-02 Update _subprocess.c from upstream Python 2.5.2 to get a few memory and reference-counting-related bugfixes.
[the full changelog is in attachment]

I built for myself matplotlib 0.91.4 from official sources and it works fine (no memory leaks), but I'm worried about other python/pylab programmers who may be not yet aware of this issue.

The bug report is my gentle request to Ubuntu Maintainers, to put matplotlib 0.91.4 in Ubuntu 8.04 repositories instead of current (buggy) version.

Greetings
   Przemek

Revision history for this message
przemkus (przemkus) wrote :
przemkus (przemkus)
description: updated
Revision history for this message
LaserJock (laserjock) wrote :

Putting matplotlib 0.91.4 in hardy-update is not really an option, there are a lot of feature additions and code changes beyond just fixing this bug. This seems serious enough though to warrant a stable release update. I'm attaching a patch I extracted from matplotlib SVN for that specific changelog entry. It seems fairly reasonable. Unfortunately I don't currently have a Hardy installation to test this out on.

Revision history for this message
Mike Droettboom (mdboom) wrote :

As the author of this patch is matplotlib's SVN, I'll second that this is a pretty critical bug and should be pushed out as a stable release update asap.

Benjamin Drung (bdrung)
Changed in matplotlib:
status: New → Fix Released
Revision history for this message
Benjamin Drung (bdrung) wrote :

Here is a debdiff for SRU. Can someone create a test case for this bug?

matplotlib (0.91.2-0ubuntu1.1) hardy-proposed; urgency=low

  * debian/patches/series: Added r4854_mathtext.patch and
    r5106_memory_leak.patch
  * Added debian/patches/r4854_mathtext.patch: Fix display of '[' and
    ']' in mathtext. (LP: #251488)
  * Added debian/patches/r5106_memory_leak.patch: Update _subprocess.c
    from upstream Python 2.5.2 to get a few memory and
    reference-counting-related bugfixes. (LP: #246239)

 -- Benjamin Drung <email address hidden> Wed, 10 Sep 2008 11:49:12 +0200

Revision history for this message
Mike Droettboom (mdboom) wrote :

I'm sorry for creating a wild goose chase. I misread the original post. The update to _subprocess.c only impacts Python < 2.4. Since Hardy ships 2.5.2, that patch should actually have no effect, though of course it's harmless.

I think we need a test case from the OP to determine the root cause of the leak he is experiencing and hopefully we can cherry-pick a patch from SVN sometime between 0.91.1 and 0.91.4 that resolves it.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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