How to clean memory after plots ?

I've done some prograss about visualising my plots from a function, but after searching in the FAQ and also in the amiling list archive i dint' find any solution to this.
I have a function that computes some data for a plot. I call the function and then use show.
Everything work fine.
Then I close all the figure (closing manually windows) and also using close() in the console (using IDLE) then I rerun the function because I need to make some changes.
But when I restart the function the precedent show() seems still active and make me all plots freeze.
Is there a way to "clean" the memory of matplotlib without restarting the shell. Because if I restart shell obviously I loose all the data the I need for redoing the calculation.
Any help very appreciated.

Giorgio Luciano wrote:

... when I restart the function ... all plots freeze.

can you give an example?

In [1]: from pylab import *

In [2]: def f(x):
   ...: return 2*x

In [8]: plot f(array(range(10)))
------> plot(f(array(range(10))))
Out[8]: [<matplotlib.lines.Line2D instance at 0x41f41ecc>]

In [9]: show
------> show()

In [10]: def f(x):
   ....: return x*x

In [11]: plot f(array(range(10)))
-------> plot(f(array(range(10))))
Out[11]: [<matplotlib.lines.Line2D instance at 0x43e0ea8c>]

In [12]: show
-------> show()

works here...