Memory problem with savefig

Hello, I have been using Matplotlib lately for some
academic research. It seem to work just fine. The only
serious problem is a problem with memory. When I run
the following code, I get the memory increasing
linearly with the time. Soon (after around 20
generations, and 100 times is this part of the program
called) I get beyond the limits of my laptop, and the
simulation ends. Considering that I need to do at
least 200 generations, you can see that it is a
serious problem.

If I comment the savefig line the memory does not
grow.
I tried to add a garbage collection but I got no
result.

Data is a list of list of data: i.e.
[[1,2,3][2,7,8][32,45,67]]
symbol2color a dictionary that for each list gives a
different color.

def fillstrip(lower,upper,color):
    reppu=upper[:]
    reppu.reverse()
    y=lower+reppu
    x1 = range(0, len(lower), 1)
    x2 = x1[:]
    x2.reverse()
    x=x1+x2
    fill(x, y, color)

def area(data,color):
    "like the area matlab function"
    lower=[0]*len(data[0])
    for (upper,c) in zip(data,color):
        upper=map((lambda x,y:x+y),lower,upper)
        fillstrip(lower,upper,c)
        lower=upper

def PlotAreaOrganization(data,filename):
    keys=symbol2color.keys()
    keys.sort()
    colors=[]
    for key in keys: colors.append(symbol2color[key])
    fig=figure(dpi=75)
    area(data,colors)
    savefig(filename)
    close(fig)

Any suggestion? Is there any other way to save a
picture that might work better?

Pietro

···

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com