How to free memory in SAGE? - Printable Version +- Tetration Forum ( https://math.eretrandre.org/tetrationforum)+-- Forum: Tetration and Related Topics ( https://math.eretrandre.org/tetrationforum/forumdisplay.php?fid=1)+--- Forum: Computation ( https://math.eretrandre.org/tetrationforum/forumdisplay.php?fid=8)+--- Thread: How to free memory in SAGE? ( /showthread.php?tid=60) |

How to free memory in SAGE? - jaydfox - 09/20/2007
Does anyone know how to free up memory in SAGE? I'm not even talking so much about being able to delete a particular variable, though that would be nice too. No, I'm talking about memory used by local variables inside functions that have already executed. Unless these values are "static", they should effectively become unusable once the function exits. BUT THEY CONTINUE TO EAT UP MEMORY!!! Eventually, I've got 2 GB of virtual memory being used by variables I can't even access, variables I was willing to throw away hours ago. Normally, I would just save my work to disk, quit, and restart, thus freeing up all the memory. But I had a session this morning that had been crunching numbers for hours, and I had so little memory left, I couldn't even save my work to disk! So please, does anyone know how to free up memory in SAGE? I'm looking for some sort of garbage collector that can look at the used memory and say to itself, "Hmm, here's 2 GB of memory sitting on a stack/heap somewhere, that isn't even referenced anymore. Maybe I should free this memory..." RE: How to free memory in SAGE? - jaydfox - 12/21/2007
For the last few months, I have continued my tradition of exiting SAGE whenever memory gets eaten up. When I need to solve a particularly large matrix system, I definitely exit and restart. Well, I had been naively blaming the problem on SAGE, but now that I know a little better, it would appear that the problem is in python. Therefore, the real question is, how do I force python to free memory? There are lots of articles I've found in a Google search that seem to address the issue, so now I just need to find a solution. It may be as simple as a python upgrade, or it may be more complex. I did find mention of a garbage collection scheme, which I'm hoping I can access from the SAGE prompt. (One thing I did notice is that lists supposedly are handled relatively efficiently, and I tend to make use of vectors, so perhaps I need to rethink my strategy?) For now, I'm sticking with the old standby: restarting often. RE: How to free memory in SAGE? - andydude - 12/21/2007
Have you tried the following? Code: `from gc import collect` Andrew Robbins |