Memory visualization

Raymond Hettinger python at rcn.com
Tue Mar 14 03:51:35 EST 2006


[bearophile]
> During the execution of a Icon script there are ways to visualize the
> memory:
> http://www.cs.arizona.edu/icon/progvis/memmon/memmon.htm
 . . .
> I'd like to know if for Python there is a similar program to
> dynamically see the memory in a similar way.
> If such tool doesn't exist yet, I'd like to know if it may be diffifult
> to create it.

Yes, it would be difficult.

Python gets chunks of memory from the o/s -- those may not be
contiguous.  Python has some internal object reuse tricks such that a
chuck of memory may be tied-up in a free-list though no active object
is alive.  Extensions can call their own malloc and free so it would be
difficult to ensure that you catch those.  Some objects like lists and
dicts have chunks of partially used memory that allow room for growth.

That being said, there is likely some interesting things that could be
done in C by exploiting tp_traverse and by hacking Python's internal
object allocator.


Raymond




More information about the Python-list mailing list