python memory usage

P

Peter Maas

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
 
I

Ivan Voras

Peter said:
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
 
P

Peter Maas

Ivan said:
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
 
A

A. Lloyd Flanagan

Peter Maas said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top