how to get memory info from python?

fishboy fishboy at spamspamspam.com
Mon Jun 7 00:12:20 EDT 2004


On Mon, 07 Jun 2004 02:44:44 GMT, "Andy C" <a at a.com> wrote:

>I posted a similar question awhile back but have not been able to get any
>info.  I wanted to see if Python could be embedded in game consoles -- but
>the lack of memory info is a dealbreaker.  If you look in google there are a
>lot of people asking this same question with no info!
>
>Andy
>
>
>
>"Gardner Pomper" <gardner at networknow.org> wrote in message
>news:mailman.637.1086562751.6949.python-list at python.org...
>> Hi,
>>
>> I'm pretty new to python, but I have not found any way to find out how
>much
>> memory is being used by my python application. I have some fairly large
>data
>> to load in and I am concerned about hitting the 2GB limit on my 32 bit
>> processes.
>>
>> I would like to have the program check itself for memory usage. I know I
>can
>> get the memory information from a 'ps -l'. Btw, I will be running on AIX
>and
>> linux, although I may do some development on Windows.
>>
>> - Gardner
>>
>>
Well.....
I little poking around in obmalloc.c came up with:

/* Print summary info to stderr about the state of pymalloc's
structures.
 * In Py_DEBUG mode, also perform some expensive internal consistency
 * checks.
 */
void
_PyObject_DebugMallocStats(void)
{
[snip]
}

obmalloc.c  also has a LOT of infomation about Pythons memory in
comments.  

So there's certainly the possibility of a roll-your-own. although
maybe only for the DEBUG build.

><{{{*>




More information about the Python-list mailing list