Memory profiling: Python 3.2

Antoine Pitrou solipsis at
Fri Nov 2 22:47:43 CET 2012

Andrew Robinson <andrew3 <at>> writes:
> When Python3.2 is running, is there an easy way within Python to capture 
> the *total* amount of heap space the program is actually using  (eg:real 
> memory)?

I'm not sure what you mean with "real memory" or how precise you want that 
measurement to be, but you could try
(and, within Python, re-use smem's concepts, which shouldn't be too difficult)

> And how much of that heap space is allocated to variables ( 
> including re-capturable data not yet GC'd ) ?

Again, not sure what you mean with "allocated to variables" (global variables? 
local variables? everything?). As for "re-capturable data not yet GC'd", the
best way to figure out is to run gc.collect() :-)



More information about the Python-list mailing list