Re: How to diagnose a kernel memory leak
From: Alexander Nyberg
Date: Wed May 18 2005 - 13:41:46 EST
If you don't do reply-to-all there's a chance people will miss out on
your mails...
> > It all looks pretty innocent. Please send the contents of /proc/meminfo
> > rather than the `free' output. /proc/meminfo has much more info.
>
> Here are the current meminfo numbers:
>
What's happening with this? It's been a week now so I'm curious.
What you can do is run the attached program, it's a simple memory eater
that will eat the amount of memory you specify, ie. "./a.out 2000" will
simply eat 2G of memory. This is because all caches get reaped to a
minimum leavel and distinguishing trouble makes is easier this way.
If you think the machine has lost memory at this time please do:
gcc memeat.c
./a.out 2000
wait until program is done
save /proc/meminfo
save /proc/page_owner
sort page_owner output
#include <stdio.h>
#include <stdlib.h>
#define page_size 4096
int main(int argc, char *argv[])
{
long size = strtoul(argv[1], NULL, 0);
long curr = 0;
printf("allocating %ldmb\n", size);
size *= 1024 * 1024;
while (curr <= size) {
char *ptr = malloc(page_size);
if (!ptr) {
printf("Couldn't allocate after %ld\n", curr);
sleep(1);
continue;
}
memset(ptr, 0, page_size);
curr += page_size;
}
return 0;
}