Why is a perl script "sleep 100" uses 100 MEGS of RAM

Why is a perl script "sleep 100" uses 100 MEGS of RAM

am 30.11.2007 17:35:44 von Ignoramus22774

I have a Fedora 8 Linux box with 64 bit OS and stock perl.

Just invoking perl executable seems to take 100 MEGS of virtual memory!

That's a huge amount. Here's proof:

work$ perl -e 'sleep 10' & sleep 1; ps -eo pid,vsz,rsz,args|grep perl |grep 'sleep 10'
[3] 15023
15023 98892 1404 perl -e sleep 10
^^^^^^^ virtual memory use

My question is, WTF is going on, why does it need so much memory all of a sudden.

For your information, on my home 32 bit linux box running Fedora 6, it uses 3 megs of VM:

home$
perl -e 'sleep 10' & sleep 1; ps -eo pid,vsz,rsz,args|grep perl |grep 'sleep 10'
[1] 27037
27037 3744 1236 perl -e sleep 10

i

Re: Why is a perl script "sleep 100" uses 100 MEGS of RAM

am 30.11.2007 18:25:55 von smallpond

Ignoramus22774 wrote:
> I have a Fedora 8 Linux box with 64 bit OS and stock perl.
>
> Just invoking perl executable seems to take 100 MEGS of virtual memory!
>
> That's a huge amount. Here's proof:
>
> work$ perl -e 'sleep 10' & sleep 1; ps -eo pid,vsz,rsz,args|grep perl |grep 'sleep 10'
> [3] 15023
> 15023 98892 1404 perl -e sleep 10
> ^^^^^^^ virtual memory use
>
> My question is, WTF is going on, why does it need so much memory all of a sudden.
>
> For your information, on my home 32 bit linux box running Fedora 6, it uses 3 megs of VM:
>
> home$
> perl -e 'sleep 10' & sleep 1; ps -eo pid,vsz,rsz,args|grep perl |grep 'sleep 10'
> [1] 27037
> 27037 3744 1236 perl -e sleep 10
>
>

You are incorrect. The output of ps is in 4K pages, so the VM size is
400MB.
Why do you care how much virtual memory is used?
Look at some of the other programs on a 64-bit system:
2808 218628 18144 /usr/libexec/gdmgreeter
^-- Yes, almost a GB to do the login screen

Neither VSZ nor RSZ mean much. VSZ corresponds to no practical
limit on a 64-bit system, and RSZ includes all linked shared libraries
that
are currently resident. The time needed to add a refcount to 1000
already
resident pages is tiny compared to the time needed to load a single
page of
code from disk, so linking to shared libraries is a very good thing.

If you want to know something more relevant about your process, run
iostat
while it runs and see how many blocks are read from disk in order to
start
your program. Divide the total by 2 and you get the amount of memory
loaded in KB (roughly). I see a few hundred blocks.
--S

Re: Why is a perl script "sleep 100" uses 100 MEGS of RAM

am 30.11.2007 22:26:20 von Joost Diepenmaat

On Fri, 30 Nov 2007 09:25:55 -0800, smallpond wrote:
> Neither VSZ nor RSZ mean much. VSZ corresponds to no practical limit on
> a 64-bit system, and RSZ includes all linked shared libraries that
> are currently resident.

Can you or anyone else tell me where to find more information about how
to interpret a processes' virtual memory stats as given by top or ps on
linux (and/or other unix-like systems). This has been bugging me for
quite a while now.

A good explanation on why they're useless (as you claim) would also be
good. I'm just trying to figure out what's what.

ps: my ps manual claims that -vsz memory is reported in 1Kb blocks (not
4k blocks as you stated)

Joost.

Re: Why is a perl script "sleep 100" uses 100 MEGS of RAM

am 30.11.2007 22:43:25 von Ignoramus22774

On 2007-11-30, Joost Diepenmaat wrote:
> On Fri, 30 Nov 2007 09:25:55 -0800, smallpond wrote:
>> Neither VSZ nor RSZ mean much. VSZ corresponds to no practical limit on
>> a 64-bit system, and RSZ includes all linked shared libraries that
>> are currently resident.
>
> Can you or anyone else tell me where to find more information about how
> to interpret a processes' virtual memory stats as given by top or ps on
> linux (and/or other unix-like systems). This has been bugging me for
> quite a while now.

man ps

s size memory size in kilobytes

i

> A good explanation on why they're useless (as you claim) would also be
> good. I'm just trying to figure out what's what.
>
> ps: my ps manual claims that -vsz memory is reported in 1Kb blocks (not
> 4k blocks as you stated)
>
> Joost.

Re: Why is a perl script "sleep 100" uses 100 MEGS of RAM

am 30.11.2007 22:55:41 von Joost Diepenmaat

On Fri, 30 Nov 2007 15:43:25 -0600, Ignoramus22774 wrote:
> man ps
>
> s size memory size in kilobytes

Yeah, well... *what* memory are we talking about? for instance, are
shared library memory sizes added to each program that uses that library?
How are copy-on-write fork/exec semantics handled etc etc.

Joost.

Re: Why is a perl script "sleep 100" uses 100 MEGS of RAM

am 01.12.2007 00:11:18 von smallpond

On Nov 30, 4:26 pm, Joost Diepenmaat wrote:
> On Fri, 30 Nov 2007 09:25:55 -0800, smallpond wrote:
> > Neither VSZ nor RSZ mean much. VSZ corresponds to no practical limit on
> > a 64-bit system, and RSZ includes all linked shared libraries that
> > are currently resident.
>
> Can you or anyone else tell me where to find more information about how
> to interpret a processes' virtual memory stats as given by top or ps on
> linux (and/or other unix-like systems). This has been bugging me for
> quite a while now.
>
> A good explanation on why they're useless (as you claim) would also be
> good. I'm just trying to figure out what's what.
>
> ps: my ps manual claims that -vsz memory is reported in 1Kb blocks (not
> 4k blocks as you stated)
>
> Joost.


You're right, it is in multiples of 1024 bytes, I was remembering
wrong. As for a reference, you could look at the kernel source
documentation for the proc filesystem, which is how ps gets its
information. Ultimately, it all comes from the process table
in the kernel.

See: Documentation/filesystems/proc.txt