Q: how to be sure if it is a kernelspace mem leak?

Joerg Beyer (J.Beyer@science-computing.de)
Mon, 20 Dec 1999 12:47:31 +0100


Hi,

I have a question conerning a memory leak. I _think_ it is in the kernel
space but I am not sure how to prove this. A few days ago I wrote a little
program and while I was in the developing cycle of edit -> compile -> run,
I found that free memory decreased. It is a little programm, starting
some thread and in the thread opening a file, close it, unlink it.
Some variables are locked with pthread semaphores.
Ok, this is not very exciting. Since the program runs only a few
seconds, I did several time the following:
cat /proc/meminfo && ./prg && cat /proc/meminfo
The free memory decreased. To get some more confidence I let the
above loop run some time and checked: the memory decreased approx linear to
number of threads and how often I run the program.
I even did this in runlevel 1.

Ok, I remembered that there should be a race in open and since this is
a MP machine it could be the cause of the memleak.

My real question is more fundamental: how can I prove that I triggered
a kernel memory leak? Is
cat /proc/meminfo && ./prg && cat /proc/meminfo
sufficient enough?

>From my understanding a userspace program can have as many memory leaks
as it likes, but if the program terminates all memory is free'd again.
[I am aware that this will not cover sys V shared memory, but my little
program does not use it. It still uses pthread semaphores.]

thanks in advance
Joerg

-- 
Any technology distinguishable from magic is insufficiently advanced.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/