# Kernel seems to just run out of memory.

## ravalox

Hey, I have a gentoo install that uses kernel 2.6.13, relatively new.  Anyways, it routinely runs out of memory and forces me to reboot.  I have an average uptime of maybe 4 days to a week, then I run out of memory and have to reboot.  I have gdesklets running, one of which tells me how much memory I have left and how much swap space I've used.  The regular set of applications I use are: gaim, gdesklets, azureus, xine, mplayer, ogle, firefox, mozilla, apache, eclipse, tomcat, quake4, ut2004, quake3, and mysql.  Not all simultaneously obviously;-)  So anyways, what I'm asking is, is this just a case of an application having a memory leak that eventually tags me out or if I need to be switching to a different kernel?  

I have a gig of ram and half a gig of swap space.

----------

## desultory

Have you checked which process is comsuming memory, with e.g. top?

----------

## ahubu

hehe, if one process is gobbling memory it should be pretty straightforward which one on day #4  :Wink:  just make sure you set your alarm clock.

So, as Desultory already suggests, use top to see what is the hogger (it's possible to sort on mem usage), or if you're more of a gnome use gnome-system-monitor.

----------

## Entropy42

Same problem here.  Top shows that X is the culprit, although the memory shown as being used by X isn't nearly as much as what is actually used on my system.

That said, X is using huge amounts of memory that aren't freed until X is killed and restarted.  xrestop doesn't show any major usage though.   :Sad: 

----------

## seventhguardian

Actualy it could be java/azureus.

I recently switched to ~x86 and had lots of lockups. On the kernel log there is this:

```

Feb  2 19:14:32 [kernel] oom-killer: gfp_mask=0x201d2, order=0

Feb  2 19:14:33 [kernel] Mem-info:

Feb  2 19:14:33 [kernel] DMA per-cpu:

Feb  2 19:14:33 [kernel] cpu 0 hot: low 0, high 0, batch 1 used:0

Feb  2 19:14:33 [kernel] cpu 0 cold: low 0, high 0, batch 1 used:0

Feb  2 19:14:33 [kernel] DMA32 per-cpu: empty

Feb  2 19:14:33 [kernel] Normal per-cpu:

Feb  2 19:14:33 [kernel] cpu 0 hot: low 0, high 186, batch 31 used:151

Feb  2 19:14:33 [kernel] cpu 0 cold: low 0, high 62, batch 15 used:45

Feb  2 19:14:33 [kernel] HighMem per-cpu: empty

Feb  2 19:14:33 [kernel] Free pages:        5740kB (0kB HighMem)

Feb  2 19:14:33 [kernel] Active:60396 inactive:60898 dirty:0 writeback:0 unstabl

e:0 free:1435 slab:2807 mapped:120334 pagetables:571

Feb  2 19:14:33 [kernel] DMA free:2088kB min:88kB low:108kB high:132kB active:53

56kB inactive:5220kB present:16384kB pages_scanned:20538 all_unreclaimable? yes

Feb  2 19:14:33 [kernel] lowmem_reserve[]: 0 0 495 495

Feb  2 19:14:33 [kernel] DMA32 free:0kB min:0kB low:0kB high:0kB active:0kB inac

tive:0kB present:0kB pages_scanned:0 all_unreclaimable? no

Feb  2 19:14:33 [kernel] lowmem_reserve[]: 0 0 495 495

Feb  2 19:14:33 [kernel] Normal free:3652kB min:2804kB low:3504kB high:4204kB ac

tive:236228kB inactive:238372kB present:507888kB pages_scanned:27192 all_unrecla

imable? no

Feb  2 19:14:33 [kernel] lowmem_reserve[]: 0 0 0 0

Feb  2 19:14:33 [kernel] HighMem free:0kB min:128kB low:128kB high:128kB active:

0kB inactive:0kB present:0kB pages_scanned:0 all_unreclaimable? no

Feb  2 19:14:33 [kernel] lowmem_reserve[]: 0 0 0 0

Feb  2 19:14:33 [kernel] DMA: 4*4kB 3*8kB 0*16kB 0*32kB 0*64kB 0*128kB 0*256kB 0

*512kB 0*1024kB 1*2048kB 0*4096kB = 2088kB

Feb  2 19:14:33 [kernel] DMA32: empty

Feb  2 19:14:33 [kernel] Normal: 195*4kB 21*8kB 3*16kB 1*32kB 1*64kB 2*128kB 3*2

56kB 1*512kB 1*1024kB 0*2048kB 0*4096kB = 3652kB

Feb  2 19:14:33 [kernel] HighMem: empty

Feb  2 19:14:33 [kernel] Swap cache: add 234568, delete 234568, find 10643/14461

, race 0+3

Feb  2 19:14:33 [kernel] Free swap  = 0kB

Feb  2 19:14:33 [kernel] Total swap = 787144kB

Feb  2 19:14:33 [kernel] Free swap:            0kB

Feb  2 19:14:33 [kernel] 131068 pages of RAM

Feb  2 19:14:33 [kernel] 0 pages of HIGHMEM

Feb  2 19:14:33 [kernel] 2199 reserved pages

Feb  2 19:14:33 [kernel] 1068 pages shared

Feb  2 19:14:33 [kernel] 0 pages swap cached

Feb  2 19:14:33 [kernel] 0 pages dirty

Feb  2 19:14:33 [kernel] 0 pages writeback

Feb  2 19:14:33 [kernel] 120334 pages mapped

Feb  2 19:14:33 [kernel] 2807 pages slab

Feb  2 19:14:33 [kernel] 571 pages pagetables

Feb  2 19:14:33 [kernel] Out of Memory: Killed process 22897 (java).

Feb  2 19:20:34 [kernel] ACPI: PCI interrupt for device 0000:00:02.7 disabled

```

Can it be this? I guess java is the cause, as I was having no trouble with azureus before starting to use ~x86.

EDIT: Usually I can't get to Top, as the system really locks up. Sometimes this happened while doing an emerge, and it seemed that "cc1plus" was the culprit, by hogging the cpu; but it happened right now, and I wasn't runing the compiler.

I never got to see the mem usage though.. Didn't suspect of a memory leak up untill now..

----------

## mariourk

 *desultory wrote:*   

> Have you checked which process is comsuming memory, with e.g. top?

 

This might sound dumb, but how do I check that?

----------

## ruben

 *mariourk wrote:*   

>  *desultory wrote:*   Have you checked which process is comsuming memory, with e.g. top? 
> 
> This might sound dumb, but how do I check that?

 

Open a terminal and run "top", then press "M" to sort by memory usage and look which processes are at the top of that list.

----------

## ruben

 *ravalox wrote:*   

> ... it routinely runs out of memory and forces me to reboot.... I have a gig of ram and half a gig of swap space.

 

What do you mean that it runs out of memory and forces you to reboot? If the kernel does run out of memory, it'll shoot down processes until it gets enough memory. But by that time, you know the meaning of "swapping hell".

----------

## mariourk

Exactly what I was looking for. Thanks a lot!   :Very Happy: 

----------

## seventhguardian

 *ruben wrote:*   

>  *ravalox wrote:*   ... it routinely runs out of memory and forces me to reboot.... I have a gig of ram and half a gig of swap space. 
> 
> What do you mean that it runs out of memory and forces you to reboot? If the kernel does run out of memory, it'll shoot down processes until it gets enough memory. But by that time, you know the meaning of "swapping hell".

 

Well, yeah! In my case it does give me a "swapping hell" and I have to manually reboot it (i.e. press the reset button..).

By the way, the problem was not just azureus. I also had the same problem with amsn cvs. This last one had a huge memory leak, silently eating up memory until the "swapping hell" gets triggered. It does this slowly, so I managed to track it down by using top. I believe it got fixed, as I had no more trouble with it since I upgraded.

In respect to azureus, I didn't try to download anything in the last months, but I believe the problem is still there.. It happens only when I have lots of files being shared, or when downloading large files.

It must be either in each of them separately, or in something they share. I had freezes running each one separately.

----------

## zxy

Is this azureus memory leak only in a certain version.

What about azureus-bin. Does it leak memory too?

----------

## syg00

Top can be run in batch mode - if I'm chasing something I set a duration and a count, and kick it off for a while. Pipe the output to disk and have a look at it later at your leisure.

Also takes a profile, so you can have it sorted as you wish - that way you can just take the first 25 (or so) lines. Whatever works for you.

Very handy for ad hoc diagnostics - hit the man page.

----------

## zxy

@syg00  could you post the comand line for using top  as you described?

----------

## syg00

I typically use something like this

```
for i in {1..10} ; do top -b -n 1 |  head -n 25  > topdata.`date +"%H%M%S"` ; sleep 60 ; done
```

Adjust as necessary.

Presumes the data is ranked as I want, else it needs sorting, which seems pointless.

Probably should script it, and use parms for the counters/sleep, but never bothered.

----------

## brot

I think this may be due to ut2004 as it doesnt exit right. when quitting the game the process is running yet, until it gets killed. So i set that ut2004 should start in a console and when quitting the game i can kill the process by pressing ctrl+c

----------

