Actual memory used by an object --- How to Determine?

A

Avi Kak

Hello:

My apologies in advance for asking a
question that probably has been raised
numerous times already in this newsgroup.
My Google search did not lead me to an
answer I could use.

Is there a Python module I could use
to determine the actual amount of memory
used by a Python object, including the
memory used by any subobjects contained
therein?

Avi Kak ([email protected])
 
J

Josiah Carlson

My apologies in advance for asking a
question that probably has been raised
numerous times already in this newsgroup.
My Google search did not lead me to an
answer I could use.

Is there a Python module I could use
to determine the actual amount of memory
used by a Python object, including the
memory used by any subobjects contained
therein?

Quick answer: No.

Long answer:
In *nix, there are various programs that tell you the amount of memory a
resident process is using, my personal favorite for process information
is ps. You may be able to query it with the proper string to find the
total amount of memory Python is using in total, which may or may not be
useful. There are utilities for windows that functionally mirror *nix
ps. Either could be run from within Python, to be processed with python
via:
a = os.popen('ps <args...>', 'r')
output = a.read()
a.close()

- Josiah
 

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
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top