# Memory Leak?

## barlad

Hey there,

I have a wierd problem with my computer. Recently I noticed that from times to times, it would get on the SWAP and start lagging. Nothing unusual you would tell me. But I have 1 gig of memory and in 3 years I have never seen my computer uses more than 700MB.

I did a "top" to figure out what was going wrong... and I found something going wrong:

 *Quote:*   

> 
> 
> top - 22:01:15 up 20 min,  3 users,  load average: 2.89, 1.25, 0.62
> 
> Tasks:  59 total,   3 running,  56 sleeping,   0 stopped,   0 zombie
> ...

 

That's the beginning of the "top" window. Process are sorted by memory usage.

I don't understand how 1,02 GIG out of 1,03 gig are used while there is not one single process that uses more than 2.5% of the Memory?

At the time I started top: I have XMMS, Kahakai, MozillaFirebird, k3b, Firestarter and some python applets running.

----------

## ckdake

AFIK,  if a program has memory leaks, it will allocate memory and not unallocate it later.  So if you quit the program with the leak or if it crashes or keeps restarting itself,  it will just keep allocating memory every time it starts and never telling the memory manager that it is done with it. Suddenly all your ram is gone and ya gotta reboot to fix it.

----------

## dsd

theres a reason behind this. its probably not a memory leak.

linux using all your ram is a *good* thing. you have a gig of ram, would you prefer it if linux left most of it alone?

linux buffers things like filesystems in available RAM, gives a nice speed boost. for example, when you save a file, it might not be saved to disk immediately, it would be stored in buffers until a certain amount of writes are queued. then it would write them all in 1 go, which is quicker than doing <x> individual writes.

take a look at the "free" output, it explains how much memory is being used for buffers. ive forgotten how to read the output, but search the forums, this question is asked a lot...

----------

## ckdake

I was thinking that was what the "buffers" part of the top output was for but its looking like top doesnt mention "cached" memory automagically.   It seems odd to me that the "buffers" would be that low and and the cache would be much higher,  my server has about 100MB in "buffers" and 100MB in "cache" all the time so I am guessing they might stay near the same, but it is a server with lots of stuff going on and that is just a guess.  But then again I don't know exactally what I am talking about and I'm just basing what I'm saying on trying to make phpsysinfo's output look different for memory usage. heh.  post back what happens.

----------

## barlad

I switched to 2.6.2. It looks much better now. I have not had any other swap access. When I do a free, I see that my whole memory is used but that at least 600MB are either cached data or buffers. 

I guess all is fine!

----------

## neuron

 *barlad wrote:*   

> I switched to 2.6.2. It looks much better now. I have not had any other swap access. When I do a free, I see that my whole memory is used but that at least 600MB are either cached data or buffers. 
> 
> I guess all is fine!

 

which 2.6 are you running now and which were you running before?

I've noticed similar behavior and I haven't gotten rid of it yet (I think I located the leak in the ati drivers though, I think it's because I use my tvout or something like that).

----------

## barlad

I am running 2.6.2-rc2, I was using 2.6.1.

----------

## mkporwit

I'm seeing some odd memory usage behavior with updatedb -- I'm running the

2.6.1 development sources, and I get the following:

bohun% free

             total       used       free     shared    buffers     cached

Mem:       1032580      42032     990548          0       4812      17492

-/+ buffers/cache:      19728    1012852

Swap:      2008116          0    2008116

bohun root # updatedb 

bohun root # free

             total       used       free     shared    buffers     cached

Mem:       1032580     418396     614184          0     141892      20968

-/+ buffers/cache:     255536     777044

Swap:      2008116          0    2008116

The memory does not seem to be getting released after updatedb finishes

running.

----------

## neuron

look into bugzilla, I THINK thats a known issue.

----------

## HomerSimpson

I have 512MB and I always hit swap. I hit very shortyly after a reboot. I run Gnome. In fact I just was at 33% swap (out of 753MB).

I have been doing ps -ax -o rss,command > some_file. Then I close gnome, do it again and then gtkdiff the two files. It shows a few things growing but X used 100MB more rss and nautilus was double the size. I tried this with the stable and ~x86 nvidia-kernel and I get the same behaviour.

I have to restart Gnome every few days or I will use up my swap. Each Gnome reboot my swap does not go back to zero. Eventually I will have to reboot the computer.

I am running 2.6.2-rc1 but I saw this behaviour with earlier 2.6 kernels as well.

I also suspected that something else was eating memory that I couldn't see so maybe updatedb is doing it as in the bugzilla report.

BTW when I am using a bunch of swap I am still showing free memory but eventually that free memory is smaller than what is used in swap so I am really out of RAM.

Why would X and Nautilus keep growing in memory usage? 

Thx

----------

## neuron

/me 's been thinking it could be the agpgart in the newer kernels actually.

----------

## HomerSimpson

My leak is in Gnome or an app run from Gnome. I need to restart Gnome every 2 to 4 days. Apgart is part of the kernel?

----------

## neuron

yes agpgart is a part of the kernel.

you could run fluxbox for a few days to see if it leaks there too.

(and shutdown all apps except from fluxbox to see if it's an app or X/kernel).

----------

## barlad

It still does it to me in 2.6.2 actually. I am thinking it might come from some program used in K3B. It looks like the leak occurs as soon as I burn a CD.

----------

## HomerSimpson

Are you running f-prot?

I have been running the update program nightly. I am going to stop using it to see if that is the cause. The reason why I bring it up is that I just ran the command line f-prot scanner (I haven't run it in a while) and my swap went up to 50%. I ctrl-C and it is now at 38% but I have a fair amount of RAM free.

----------

## neuron

nope, no f-prot running :/

----------

## HomerSimpson

After removing f-prot, I didn't notice a difference. Athough it has only been a night or two since I stopped running it at night.

I did however stop running xfwm4 as my Window Manager for Gnome and immediately I gained ram and my swap went down to 9% where it was always 11% and higher. I am going to run like this for a few days to see if my "memeory leak" is still there. Maybe xfwm4 and Gnome were not made for each other.

----------

## thundersteele

ati-drivers have a memory leak. If some of you are using them, this could be the reason.

----------

## HomerSimpson

I am using nVidia.

Now that I have dropped xfwm4 and am running metacity again, my RAM situation looks much better. I am going to run like this for another day or two before I say xfwm4 was my problem.

Update

Running Metacity definitely shows more RAM available but after running updatedb my free RAM disappears. I am talking about the -/+ buffers/cache: line when running free. But when I run any other program and then exit it, my -/+ buffers/cache: line shows more RAM free. When running system monitor it shows that I have a lot of RAM available. It certainly disagrees with free. hmmmm. Confusing.

There have been so many posts about how Linux uses RAM. You just can't figure it out. The tools are nice but wrt free RAM I am not sure it tells me anything useful. 

"It is like asking the square root of a million -- no one will ever know." 

-- Nelson Muntz

----------

## radulucian

same problem here

free says:

 *Quote:*   

> 
> 
>              total       used       free     shared    buffers     cached
> 
> Mem:        904812     864516      40296          0     243032     249560
> ...

 

i am not hiting swap yet, but i am not using any x at all.

is that buffer and cache of 250 megs ok ?

system was only running for couple of hours with some heavy apache and mysql but stoping them makes no difference. 

i am using gentoo-dev-sources with 2.6.4 kernel.

pls help

----------

## ckdake

lots of buffer and cache are good. that is the way that linux memory management works. It sticks lotsa stuff in ram that you might need so if you need it it will be there already.

----------

