473,668 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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



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
1 1821
> 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
379
by: zooko | last post by:
Here some some functions I've used to analyze memory usage in the past. http://mnetproject.org/repos/pyutil/pyutil/memutil.py There may be bugs. If so, please fix them or at least report them. Regards, Zooko
9
2471
by: Chris S. | last post by:
Is it possible to determine how much memory is allocated by an arbitrary Python object? There doesn't seem to be anything in the docs about this, but considering that Python manages memory allocation, why would such a module be more difficult to design than say, the GC?
2
2368
by: Arthur M. | last post by:
Does anyone know of a way to pin point true memory utilization on a per object / allocation basis in dot net. The problem that i'm having is projecting the amount of memory that will be required by an application. Obviously there is a component size (i.e. a class that is using 2 32bit integers will use 8byte) but then there is a question of overhead for .NET management (i.e. vtables, lookup tables, garbage collector pointer on a per...
9
2433
by: CptDondo | last post by:
I am working on an embedded platform which has a block of battery-backed RAM. I need to store various types of data in this block of memory - for example, bitmapped data for control registers, strings for logging, and structures for data points. I want to use one function to read data from this block and one function to write data, for example: sram_read(OBJECT_IDENTIFIER) would return a pointer to the appriate object and
62
17748
by: ivan.leben | last post by:
How can I really delete a preloaded image from memory/disk cache? Let's say I preload an image by creating an Image object and setting its src attribute to desired URL: var img = new Image(); img.src = ; Then I use the image a few more times by adding it into an Array object:
10
2055
by: goose | last post by:
Hello all I've written a wrapper for malloc and friends. Its available from http://www.lelanthran.com/downloads/os_mem/index.php The reason for doing writing this so that newbies can finally get answers to the following newbie questions:
6
380
by: pauldepstein | last post by:
Could anyone explain (by giving a URL possibly) how to solve problems of the form "How much memory does the following piece of code take?" For example, consider the declaration/definition int x; How much memory does it take? Is the answer the size of the integer range. I think this is something
14
4061
by: Joe | last post by:
I'm trying to track down where objects are referenced because I want to clean up the memory when I'm done with them. I thought I found all references but it doesn't seem that way because calling GC.Collect() doesn't free very much. I ran the built-in profiler and I get a warning: "An abnormal percentage of objects were collected in generation 2, which is inefficient. Investigate further by using the Objects Lifetime view." The top 3...
3
2461
by: crazy420fingers | last post by:
I'm running a python program that simulates a wireless network protocol for a certain number of "frames" (measure of time). I've observed the following: 1. The memory consumption of the program grows as the number of frames I simulate increases. To verify this, I've used two methods, which I invoke after every frame simulated:
0
8382
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8893
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8802
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8658
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7405
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1787
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.