how to get memory info from python?

G

Gardner Pomper

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
 
A

Andy C

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
 
F

fishboy

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
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.
 
L

Lothar Scholz

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

But obmalloc.c has a high performance penalty and can't be recommend
for productivity systems that must work on a game console.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top