[Tutor] memory consumption
eryksun
eryksun at gmail.com
Wed Jul 3 22:07:01 CEST 2013
On Wed, Jul 3, 2013 at 2:17 PM, Andre' Walker-Loud <walksloud at gmail.com> wrote:
>
> I had assumed that reusing a variable name in a loop would automatically
> flush the memory by just overwriting it. But this is probably wrong.
CPython uses reference counting and a garbage collector that breaks
cycles (see gc.collect). You can use sys.getrefcount() to check the
count (subtract 1 for the call). Also, an extension type may allocate
memory for caches and such (e.g. numpy's fft), and you may not have
direct control over this.
Try a memory profiler:
https://pypi.python.org/pypi/memory_profiler
More information about the Tutor
mailing list