Can I get the total memory usage of Python?

Cameron Laird claird at lairds.com
Fri May 23 09:51:40 EDT 2003


In article <bakq69$bhd$04$1 at news.t-online.com>,
Martin v. Löwis <martin at v.loewis.de> wrote:
>Haigu wrote:
>
>> I'm embedding python in my program, and now I want to fully test my program
>> to check for memory leaks. So is there any way to know how much memory is
>> used by python?
>> 
>> Also is there any way to know how many certain kind of objects are
>> allocated? say, how many intergers ?
>
>In the release build, you can only find out how many container objects 
>you have, with gc.getobjects(). In the debug build, you can get a list 
>of all objects, which you can traverse to count them by type.
			.
			.
			.
What's the feasibility of an enhancement in a future
version of Python to provide greater introspective
power in regard to memory allocation?  I'll naively
speculate that, if we can just agree on an interface,
it should impose no particular runtime costs; every-
thing necessary is already available on the C side,
and needs only to be exposed.
-- 

Cameron Laird <Cameron at Lairds.com>
Business:  http://www.Phaseit.net
Personal:  http://phaseit.net/claird/home.html




More information about the Python-list mailing list