473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How to measure memory footprint of Python objects?

Hello everybody,

I try to solve the following problem: I have a python program that takes a
lot of memory (>hundred Mb). I made an improvement (I hope) and I want to
measure the gain (if possible on several platforms). I would like to be able
to print the max memory taken during the run upon exiting my Python program
(like I already do for the time taken to run).

I can see the total process size of the Python process (Task manager on MS
Win or Unix "ps" command) but that is not precise enough for me and also not
convenient. I don't care about the python interpreter overhead, I'm
interested only in the total size of Python objects allocated by my program.
Is there a Python way to get that (meaning without resorting to
non-portable, less precise OS features)?

I would like to get that size at different given moments in time to make up
a timeline of memory consumption. But, if that is too tricky, I would be
happy to just get the maximum.

Any suggestion welcome,
Adrian.
Sep 20 '06 #1
3 3399
"Neagu, Adrian" <Ad**********@nuance.comwrites:
I would like to get that size at different given moments in time to make up
a timeline of memory consumption. But, if that is too tricky, I would be
happy to just get the maximum.

Any suggestion welcome,
See the docs for the gc module.
Sep 20 '06 #2
Paul Rubin wrote:
See the docs for the gc module.
This is the first place I've checked. I see no useful info there about
the actual size of the objects (bytes occupied in memeory).

The closest thing to what I need is get_objects( ). Then I have to go
over the list
and do something with the objects. Wouldn't that be too slow?

Thanks anyway,
Adrian.

Sep 20 '06 #3
Neagu, Adrian wrote:
I try to solve the following problem: I have a python program that takes a
lot of memory (>hundred Mb). I made an improvement (I hope) and I want to
measure the gain (if possible on several platforms). I would like to be able
to print the max memory taken during the run upon exiting my Python program
(like I already do for the time taken to run).
You could try PySizer: http://pysizer.8325.org/

--
Heikki Toivonen
Sep 21 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Roy Smith | last post by:
I understand that psyco significantly increases memory use. Is that for code or data? More specifically, if I've got a memory intensive application (it might use 100's of Mbytes of data), should...
2
by: Mike Peretz | last post by:
I am trying to optimize my C# program, but no matter what I try the application keeps eating memory. I verified all the references and even got special software to count references. I made sure all...
1
by: Derrick | last post by:
Thanks to many on this newsgroup, I now have a prototype Windows Forms C# app that reads xml documents into DataSets via XmlDataDocument, and does *stuff* with it. I basically have about 25 megs...
3
by: Derrick | last post by:
I am reading in xml files that equate to sql tables, via XmlDataDocument, and then operating on the DataSet. With the most simple app that just loads the xml doc, I see the memory footprint of the...
8
by: Bob Dufour | last post by:
We got a windows form application that we wrote in VB.Net. Essentially its a manager for a list of persons and their contacts and some other info about the persons. No rocket science but lots of...
3
by: Rune Strand | last post by:
Is there a way to measure how much memory a data structure use? For instance, what is the footprint of a particular list object like ?
0
by: Adrian Neagu | last post by:
Hello everybody, I try to solve the following problem: I have a python program that takes a lot of memory (>hundred Mb). I made an improvement (I hope) and I want to measure the gain (if possible...
1
by: nazgul | last post by:
Hi all, I have an app that runs on multiple boxes. On my slackware box, running Python 2.5.1, top shows this: Mem: 1002736k total, 453268k used, 549468k free, 31392k buffers Swap: ...
0
by: arobinson | last post by:
I am a developer relatively new to python and brand new to pygtk development. I wanted to write a bloglines tray icon notifier for my linux box. Everything is working quite well functionality wise,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.