[Numpy-discussion] how do I delete unused matrix to save the memory?
Wed Dec 10 11:56:39 CST 2008
I am running in ipython. Now I do not have the problem anymore. %reset commands is a good solution.
Frank> Date: Tue, 9 Dec 2008 21:03:00 -0600> From: email@example.com> To: firstname.lastname@example.org> Subject: Re: [Numpy-discussion] how do I delete unused matrix to save the memory?> > On Mon, Dec 8, 2008 at 19:15, frank wang <email@example.com> wrote:> > Hi,> >> > I have a program with some variables consume a lot of memory. The first time> > I run it, it is fine. The second time I run it, I will get MemoryError. If I> > close the ipython and reopen it again, then I can run the program once. I am> > looking for a command to delete the intermediate variable once it is not> > used to save memory like in matlab clear command.> > How are you running this program? Be aware that IPython may be holding> on to objects and preventing them from being deallocated. For example:> > In : !cat memtest.py> class A(object):> def __del__(self):> print 'Deleting %r' % self> > > a = A()> > In : %run memtest.py> > In : %run memtest.py> > In : %run memtest.py> > In : del a> > In :> Do you really want to exit ([y]/n)?> > $ python memtest.py> Deleting <__main__.A object at 0x915ab0>> > > You can remove some of these references with %reset and maybe a> gc.collect() for good measure.> > > In : %run memtest> > In : %run memtest> > In : %run memtest> > In : %reset> Once deleted, variables cannot be recovered. Proceed (y/[n])? y> Deleting <__main__.A object at 0xf3e950>> Deleting <__main__.A object at 0xf3e6d0>> Deleting <__main__.A object at 0xf3e930>> > -- > Robert Kern> > "I have come to believe that the whole world is an enigma, a harmless> enigma that is made terrible by our own mad attempt to interpret it as> though it had an underlying truth."> -- Umberto Eco> _______________________________________________> Numpy-discussion mailing list> Numpyfirstname.lastname@example.org> http://projects.scipy.org/mailman/listinfo/numpy-discussion
Send e-mail faster without improving your typing skills.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion