By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,996 Members | 1,343 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,996 IT Pros & Developers. It's quick & easy.

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

P: n/a


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 (ka*@purdue.edu)
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> 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
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.