473,508 Members | 2,152 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

python memory usage

In a recent discussion somebody claimed that python executable has
a huge memory consumption compared to perl and tcl, about 18 MB.
I didn't believe that and checked on my machine (SusE 7.3, Linux
2.4, Perl 5.6.1, Python 2.3.2, Tcl 8.3), command
ps -o "cmd rss vsize", results in kBytes:

CMD RSS VSZ
perl 984 2760
python 2556 4188
tclsh8.3 1100 2316

But python (contrary to perl) starts an interactive interpreter which
doesn't matter when executing scripts. To get rid of it I created
a fifo (mknod xxx p) and started all programs with 'prog xxx'.
The result:

CMD RSS VSZ
perl 892 2736
python 544 2424
tclsh8.3 1100 2316

The fifo keeps Python in working memory but since the input isn't
a tty, the interactive interpreter isnt't started. Is this a
reasonable comparison or did I miss something?

Mit freundlichen Gruessen,

Peter Maas

--
-------------------------------------------------------------------
Peter Maas, M+R Infosysteme, D-52070 Aachen, Hubert-Wienen-Str. 24
Tel +49-241-93878-0 Fax +49-241-93878-20 eMail pe********@mplusr.de
-------------------------------------------------------------------
Jul 18 '05 #1
3 2133
Peter Maas wrote:
But python (contrary to perl) starts an interactive interpreter which
doesn't matter when executing scripts. To get rid of it I created
a fifo (mknod xxx p) and started all programs with 'prog xxx'.
Why didn't you just make a python script that does nothing (maybe
something like "while 1: pass")?
The result:

CMD RSS VSZ
perl 892 2736
python 544 2424
tclsh8.3 1100 2316

The fifo keeps Python in working memory but since the input isn't
a tty, the interactive interpreter isnt't started. Is this a
reasonable comparison or did I miss something?


It cold be ok, but the second rss number seems a bit low. Here (Python
2.3, FreeBSD 4.9) it looks like this:

tty-interpreter mode: rss: 2684, vsz: 3460
running the one-lined empty loop script: rss: 2212, vsz: 2992
"running" an disconnected fifo: rss: 1296, vsz: 1992
Jul 18 '05 #2
Ivan Voras wrote:
Why didn't you just make a python script that does nothing (maybe
something like "while 1: pass")?
Fifo was simpler than writing three scripts for tcl, perl and python.
And I wanted a clean comparison with Perl waiting for data from stdin,
a zero test case.
It cold be ok, but the second rss number seems a bit low. Here (Python
2.3, FreeBSD 4.9) it looks like this:

tty-interpreter mode: rss: 2684, vsz: 3460
running the one-lined empty loop script: rss: 2212, vsz: 2992
"running" an disconnected fifo: rss: 1296, vsz: 1992


Similar results on my machine:

python one-lined empty loop rss: 2148 vsz: 3608
perl one-lined empty loop rss: 1112 vsz: 2756
tclsh8.3 one-lined empty loop rss: 1096 vsz: 2316

Strange that starting an empty loop makes such a difference for python.
Anyway, the numbers are in a reasonable range, unlike the 18 MB than
came up in a discussion. Thanks for comparing.

Mit freundlichen Gruessen,

Peter Maas

--
-------------------------------------------------------------------
Peter Maas, M+R Infosysteme, D-52070 Aachen, Hubert-Wienen-Str. 24
Tel +49-241-93878-0 Fax +49-241-93878-20 eMail pe********@mplusr.de
-------------------------------------------------------------------
Jul 18 '05 #3
Peter Maas <fp********@netscape.net> wrote in message news:<c0**********@swifty.westend.com>...
In a recent discussion somebody claimed that python executable has
a huge memory consumption compared to perl and tcl, about 18 MB.
I didn't believe that and checked on my machine (SusE 7.3, Linux
2.4, Perl 5.6.1, Python 2.3.2, Tcl 8.3), command
ps -o "cmd rss vsize", results in kBytes:

CMD RSS VSZ
perl 984 2760
python 2556 4188
tclsh8.3 1100 2316


Has anybody got comparable figures for a Java process?
Jul 18 '05 #4

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

Similar topics

4
5000
by: ulysses | last post by:
hi, I'm working in python 5 months. I think it's very cool language. I do a p2p python program GUI. First I make a software by wxpython. But I find wxpython use many many memory. Second I use...
8
2091
by: Sridhar R | last post by:
Hi, I am a little experienced python programmer (2 months). I am somewhat experienced in C/C++. I am planning (now in design stage) to write an IDE in python. The IDE will not be a simple...
0
1572
by: Robby Dermody | last post by:
Hey guys (thus begins a book of a post :), I'm in the process of writing a commercial VoIP call monitoring and recording application suite in python and pyrex. Basically, this software sits in a...
25
5706
by: abhinav | last post by:
Hello guys, I am a novice in python.I have to implement a full fledged mail server ..But i am not able to choose the language.Should i go for C(socket API) or python for this project? What are the...
13
4458
by: placid | last post by:
Hi All, Just wondering when i run the following code; for i in range(1000000): print i the memory usage of Python spikes and when the range(..) block finishes execution the memory usage...
3
3422
by: test.07 | last post by:
I am wondering what happens to a thread in python in relation to win32com extensions. If I create a new thread, that uses the Dispatch method from win32com, what happens to the memory allocated...
17
8454
by: frederic.pica | last post by:
Greets, I've some troubles getting my memory freed by python, how can I force it to release the memory ? I've tried del and gc.collect() with no success. Here is a code sample, parsing an XML...
0
3067
by: greg.novak | last post by:
I am using Python to process particle data from a physics simulation. There are about 15 MB of data associated with each simulation, but there are many simulations. I read the data from each...
1
1712
by: yzghan | last post by:
Hi all, I feel that my python script is leaking memory. And this is a test I have: log.write(" " + "test() ... memory usage: " + " ".join(repr(i/(1024*1024)) for i in getMemInfo()) + "\n") m...
1
2021
by: Jean-Paul Calderone | last post by:
On Tue, 22 Apr 2008 14:54:37 -0700 (PDT), yzghan@gmail.com wrote: The test doesn't demonstrate any leaks. It does demonstrate that memory usage can remain at or near peak memory usage even after...
0
7225
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
7124
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
7326
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
7385
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...
0
7498
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
5629
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,...
0
1558
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 ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
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...

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.