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

python memory usage

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.