Memory usage of an 'empty' python interpreter

N

neokosmos

I was wondering what the approximate amount of memory needed to load a
Python interpreter (only, no objects, no scripts, no nothing else) in a
Linux 2.6 environment. According to ps, it appears to be 3312 bytes,
which seems absurdly low to me. However, when I check the size of my
Python executable, it looks like it is only about 5600 bytes in size,
so maybe this is reasonable?

Right now, I currently have one bare Python interpreter running and no
other Python programs. Here is the output of ps -aux | grep python
(headers added for readability):

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME
COMMAND
paul 17561 0.1 0.6 14616 3312 pts/2 S+ 02:33 0:00 python
paul 17569 0.0 0.1 2600 520 pts/3 R+ 02:34 0:00 grep
python

If I am reading this right, it says the Python interpreter itself is
using 3312 bytes of memory, but has 14616 bytes of shared memory it can
access (which, i assume, is mostly shared libraries).

Here's my ls -l /usr/bin/python2.4:

-rwxr-xr-x 1 root root 5424 Jul 21 08:02 /usr/bin/python2.4

Am I interpreting this stuff more or less correctly?

Thanks!
 
A

Ant

I was wondering what the approximate amount of memory needed to load a
Python interpreter (only, no objects, no scripts, no nothing else) in a
Linux 2.6 environment. According to ps, it appears to be 3312 bytes,
which seems absurdly low to me. However, when I check the size of my
Python executable, it looks like it is only about 5600 bytes in size,
so maybe this is reasonable?

Are you sure ps is reporting in bytes not KB? The bare interpreter in
Windows is 3368KB.
On my Gentoo server ps reports 2788KB for the bare interpreter.
 
G

Ganesan Rajagopal

neokosmos said:
I was wondering what the approximate amount of memory needed to load a
Python interpreter (only, no objects, no scripts, no nothing else) in a
Linux 2.6 environment. According to ps, it appears to be 3312 bytes,
which seems absurdly low to me. However, when I check the size of my
Python executable, it looks like it is only about 5600 bytes in size,
so maybe this is reasonable?

It is, when you consider that ps reports in kilobytes :). It's
meaningless just to compare the size of the python binary. In your case it's
obvious that the python binary is linking to a shared python library.

Ganesan
 
S

sjdevnull

I was wondering what the approximate amount of memory needed to load a
Python interpreter (only, no objects, no scripts, no nothing else) in a
Linux 2.6 environment. According to ps, it appears to be 3312 bytes,
which seems absurdly low to me.

Your spidey sense is working properly, 3312 bytes is absurdly low.
Here is the output of ps -aux | grep python

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME
COMMAND
paul 17561 0.1 0.6 14616 3312 pts/2 S+ 02:33 0:00 python [SNIP]
If I am reading this right, it says the Python interpreter itself is
using 3312 bytes of memory, but has 14616 bytes of shared memory it can
access (which, i assume, is mostly shared libraries).

Nope, ps output for those values is in kilobytes. It's a bit over 3 MB
RSS, 14MB shared.
Here's my ls -l /usr/bin/python2.4:

-rwxr-xr-x 1 root root 5424 Jul 21 08:02 /usr/bin/python2.4

I'm not sure what's up here (maybe a shell script wrapper?) try "file
/usr/bin/python2.4" and "ls -alh /usr/bin/python2.4".
 
J

John Machin

Ant said:
Are you sure ps is reporting in bytes not KB? The bare interpreter in
Windows is 3368KB.

Where did you get that from? With Python 2.4.3, on my machine (Win XP
SP2):

C:\junk>dir \python24\python*
[snip]
29/03/2006 05:35 PM 4,608 python.exe
29/03/2006 05:35 PM 1,871,872 python24.dll
29/03/2006 05:35 PM 5,120 pythonw.exe
 
A

Ant

Are you sure ps is reporting in bytes not KB? The bare interpreter in
Windows is 3368KB.

Where did you get that from? With Python 2.4.3, on my machine (Win XP
SP2):

C:\junk>dir \python24\python*
[snip]
29/03/2006 05:35 PM 4,608 python.exe
29/03/2006 05:35 PM 1,871,872 python24.dll
29/03/2006 05:35 PM 5,120 pythonw.exe

He's asking for the memory required, not the disk space used by the
exe. The 3368KB is reported by the Task Manager.
 
J

John Machin

Ant said:
Are you sure ps is reporting in bytes not KB? The bare interpreter in
Windows is 3368KB.

Where did you get that from? With Python 2.4.3, on my machine (Win XP
SP2):

C:\junk>dir \python24\python*
[snip]
29/03/2006 05:35 PM 4,608 python.exe
29/03/2006 05:35 PM 1,871,872 python24.dll
29/03/2006 05:35 PM 5,120 pythonw.exe

He's asking for the memory required, not the disk space used by the
exe. The 3368KB is reported by the Task Manager.

Doh! Low blood sugar -- that's the excuse du jour :)

Cheers,
John
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top