[MPlayer-users] Help! XFree86 4.1.0 crashing when...

Gábor Lénárt lgb at lgb.hu
Sun Oct 14 19:28:37 CEST 2001


On Sun, Oct 14, 2001 at 07:34:12PM +0300, Steve Stavropoulos wrote:
> On Sun, 14 Oct 2001, Arpi wrote:
> 
> > Hi,
> >
> > > > > >          Ram: 1004 MB
> > > > > >         Swap: 2000 MB
> > maybe he just read in that funny linux books that swap should be 2 times ram
> > size... it was true at 8-16mb ram time...
> >
> 
>  And still is! As a general rule it's fine to have swap=2xram, if you 've
> got 1Gb of Ram then 2gb of your disk should be nothing for you.
> 

Fine but what? It was a VM error of kernel when you had to have 2xram swap.
If you have got enough RAM what's the advantage of swap? It can even make
things more stupid: currently almost every 2.4.x systems have got some
bug in VM to start wasting swap and eating CPU (by kswapd kernel daemon)
if you have swap while if you haven't got any swap it stays cool (the VM
bug is not affected in swap mechanisms, since there is no swapping at all :).
As the point of view of user process, total memory is RAM + swap. If someone
has got 64Mb RAM and 128M this is 192M. This is almost exactly if you have got
192M RAM and no swap at all. With 1G of RAM it must be fine without any swap
(I'm using 2.4.10 on two machines without any swap with 256Mb RAM, with quite
big loads. no problem here).

mplayerhq.hu also runs without any swap.

> [steve at Paradise img]$ uname -a
> Linux Paradise.NotHere 2.4.10 #1 Mon Sep 24 11:49:47 EEST 2001 i686 unknown
> 
> [steve at Paradise img]$ free -m
>              total       used       free     shared    buffers     cached
> Mem:           502        498          3          0          1        151
> -/+ buffers/cache:        346        155
> Swap:          252         36        215
> 
>  You should note that this is just my personal PC for general use. Look at
> some programms I run:
> 
> Programm	Ram Size	RSS
> X		124Mb		70Mb
> mozilla		68992Kb		66Mb
> gimp		23762Kb		23Mb
> squid		13512Kb		13Mb
> xmms		11408Kb		11Mb
> 
> shall I continue?

You CAN continue. however ...

I have got very similar results with 256Mb RAM and no swap. Imho (I'm not
sure though) RAM size is the total used addressing space which includes
shared libraries and shared memory blocks as well. Shared with OTHER
processes. Let me explain. With 64Mb of RAM (my old computer) and about 96Mb
swap I saw process sizes sum of almost 1Gb!!!! This is of course impossible
so I got the idea, that vary large amount of memory is shared between processes,
like all of shared libs. 

A simple program like this:

int main ( void ) { for (;;) ; }

Compile, and launch it. Then look in /proc/<pid>/status:

VmSize:     1264 kB
VmLck:         0 kB
VmRSS:       276 kB
VmData:       20 kB
VmStk:         8 kB
VmExe:         4 kB
VmLib:      1200 kB

Can you understand? The executable is only 4K (well, it can be smaller, but
memory allocation is page based which is 4K on intel). Stack is 8K, data is
20K. But the size of process is 1264K!!!!!! Of course from this 1264K 1200K
is shared library (now it can be libc) ...

Also VmRSS is not the size of program, as you can see VmRSS != VmData+VmStack+
VmExe), cause by for example mmaps which does not require RAM only virtual
address space (of course some memory is taken from pagecache or whatever
but that's dynamic imho).

Now, top reports about this process:

  PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME COMMAND
23946 lgb       16   0   276  276   224 R    99.2  0.1   4:34 test

So as you can see, VM subsystem is not too easy to understand but it's
not true you've calculated in your letter.

See my X server:

  PID USER     PRI  NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME COMMAND
24002 root       5 -10 58624 9.9M  2576 S <   0.1  3.9   0:03 XFree86

VmSize:    60968 kB
VmLck:         0 kB
VmRSS:     10520 kB
VmData:    14460 kB
VmStk:        76 kB
VmExe:      1292 kB
VmLib:      1388 kB

However I'm far from being Linux VM expert but I know protected mode
and OS desiging quite well on intel CPUs so I have got some idea on this
topic. But feel free to correct me, this letter is "IMHO".

- Gabor



More information about the MPlayer-users mailing list