Memory leak with dev_add_pack()
From: anish kumar <hidden>
Date: 2011-01-23 17:29:54
Hi! On 21:22 Sun 23 Jan , anish kumar wrote:quoted
quoted
The funny point is that buffer_head belongs to the filesystem subsystem. What file systems are you using? Could it be that your code just triggers the memory leak, because data is logged to disk, e.g. to /var/log/kern.log ?I did small experiment with your code.I removed all your logs which were getting logged in kernel buffers(kern.log).With this change i checked the "meminfo" and found that the memory leaking is almost same as compared to normal case(with no change in your code).quoted
I have tried your program on my virtual machine (2.6.28) and could see any leak, but maybe data is leaked very slowly...i confirm that data is leaking very slowly (below is the output i got on my ubuntu machine with removed logs from your code). $date Sun Jan 23 19:13:47 RET 2011 $ head -n5 /proc/meminfo MemTotal: 1018172 kB MemFree: 373708 kB Buffers: 32232 kB Cached: 296004 kB SwapCached: 0 kB $ date Sun Jan 23 19:15:03 RET 2011 $ head -n5 /proc/meminfo MemTotal: 1018172 kB MemFree: 373584 kB Buffers: 32248 kB Cached: 296004 kB SwapCached: 0 kB With logs enabled in your code i can see marginal increase in leaking memory.This small increase could easily be caused by background activity. Please try to reproduce this in single user mode with all file systems mounted read-only (use e.g. "mount -o remount,ro /") and no processes running except init and your shell. Then see if memory increase is both correlated to network traffic and reason of system crashes. If it takes too long, you can add e.g. "mem=32M" to the kernel boot parameter list in the bootloader.
Thanks for this suggestions. After persuading my kernel to use only 100M(with 32M system not booting,it is not vanilla kernel) of my physical memory and after installing your ko i tried to check meminfo and found that the claim made by you(.ko is leaking memory) may not be true as i can see in the output of /proc/meminfo,MemFree is sometimes increasing and sometimes decreasing(could be because of several other components). I can say with certainty that your ko looks fine to me after this testing. I couldn't see any panic happening in my system( system is running fine under such low memory). However i see that several other applications(xserv) is crashing because of out of memory which i think is fine. ps:I dont have vanilla kernel where i could have changed the intitialisation files to remount while booting and could have controlled the list of process running on the system. In android we are doing that in init.rc file need to check in ubuntu.
-Michi -- programing a layer 3+4 network protocol for mesh networks see http://michaelblizek.twilightparadox.com