Can I get the total memory usage of Python?

Daniel Fackrell unlearned at DELETETHIS.learn2think.org
Fri May 23 13:34:02 EDT 2003


Cameron Laird wrote:
> In article <mailman.1053701439.24056.python-list at python.org>,
> Tim Peters  <tim.one at comcast.net> wrote:
>> Except that there's no standard way in C to query the platform
>> malloc about how much memory it's actually using, and all mallocs
>> have hidden overheads. When allocating a large number of small
>> objects, malloc overhead can be more than half the story.  In 2.3
>> pymalloc takes most of that out of the platform malloc's hands
>> (although it still grabs *large* chunks from the platfrom malloc,
>> and pymalloc still can't know how much overhead the platform malloc
>> chews up for those).
>
> Right; it's a general principle of common OSs that
> t's shockingly hairy to find out what is *really*
> going on in memory.
>
> What I meant, although far too elliptically, was just
> at the pymalloc level.  No, that doesn't correspond
> to real memory use, as seen "from the outside"; my own
> intentions for memory introspection are satisfied by
> anything which reliably enumerates my use of memory,
> even if it's inaccurately quantified.  It's enough
> for me to have a handle on how many and which objects
> I'm asking the system to juggle.

I have begun work on collaborative system that will eventually allow people
to edit and create code for long-lived, persistent objects in a running
server (MUD-type application).  For this sort of thing, it would be helpful
to be able to provide the administrators with a general idea of how memory
is being used with respect to time.

One possible use would be to track down plugin modules that are creating
disposable objects, but not destroying all references, leading to a good
old-fashioned leak.  Even it can't be isolated to a particular location,
knowing that a leak exists is a good first step toward finding and
eradicating it.  A general idea of the rate of leakage is probably a close
second.

--
Daniel Fackrell (newsgroups.NOSPAM at dfackrell.mailshell.com)
When we attempt the impossible, we can experience true growth.






More information about the Python-list mailing list