I'm working on a Linux kernel driver, and it probably has memory leak
somewhere. I'm looking for a Linux unitiliy or tool that I can use to check
the amount of memory while my driver is running. This way, I can probably
easily tell if it has memory leak or not (see if the available memory keep
droping while my driver is running). Could someone tell me what Linux
utility/tool can I use for checking the available memory?
Thanks,
T.
Probably? You really ought to know! DO you use memory (kmalloc) and
free it (kfree)? If so, count it in and count it out. Print out the
differences.
> the amount of memory while my driver is running. This way, I can probably
Add an output for yourself in /proc or via an ioctl.
> easily tell if it has memory leak or not (see if the available memory keep
> droping while my driver is running). Could someone tell me what Linux
> utility/tool can I use for checking the available memory?
Look in /proc, or hit a weird ctrl-alt-syslock-something combo I can
never remember, or "man free". But this question is a silly question
coming from a kernel author. "man printk"!
Peter
Several, free/top/ps or just 'cat /proc/meminfo' should do. I'd use in
addition 'xosview' in this case, it's a GUI tool making memory and VM
allocation visible.
--
Michael Heiming
Remove +SIGNS and www. if you expect an answer, sorry for
inconvenience, but I get tons of SPAM
> Probably? You really ought to know! DO you use memory (kmalloc) and
> free it (kfree)? If so, count it in and count it out. Print out the
> differences.
[Followup set to system group.]
I think that's what he's asking for, a set of tools that make it easier to
track this information. Even the most disciplined programmer makes
mistakes, so tools that help to find those mistakes are essential.
In the application space there are tools like Purify. What comparable tools
exist in kernel space to assist in matching kmalloc with kfree?
--
Kenneth Porter
http://www.sewingwitch.com/ken/
None. There are no tools in kernel space. Nothing except Zen and Deep
Thought. He can add a counter and put in his own printks or ioctls.
Peter
>> In the application space there are tools like Purify. What comparable tools
>> exist in kernel space to assist in matching kmalloc with kfree?
>
> None. There are no tools in kernel space. Nothing except Zen and Deep
> Thought. He can add a counter and put in his own printks or ioctls.
There are lots of tools actually.
The old IKD patchkit (somewhere in
ftp://ftp.kernel.org/pub/linux/kernel/people/andrea/) used to have an option
to track memory leaks. It is not as sophisticated as the user space tools
and may need a bit of porting for newer kernels, but may help.
Another useful tool to find memory leaks is /proc/slabinfo. It tells
you what slab cache or kmalloc bucket size is leaking.
The 2.6-mm* kernels have a CONFIG_DEBUG_PAGEALLOC option. It unmaps freed
pages from the kernel mapping. This is useful to find use-after-free.
All kernels have the CONFIG_DEBUG_SLAB option. It adds redzones around
many allocated memory objects and checks them and poisons freed
objects. This is very useful to find memory allocation problems.
-Andi
P.S.: The cross posting is evil.
I think "cat /proc/meminfo" is good enough for me at this time. One more
question...how can I make a demeon and let it keep running and invoke "cat
/proc/meminfo" to send memory info to a text file, say every 10 minutes?
Thanks,
T.
"Michael Heiming" <michael...@www.heiming.de> wrote in message
news:0vkthb...@news.heiming.de...
> question...how can I make a demeon and let it keep running and invoke "cat
> /proc/meminfo" to send memory info to a text file, say every 10 minutes?
cron.
>>> I'm working on a Linux kernel driver, and it probably has memory leak
>>> somewhere. I'm looking for a Linux unitiliy or tool that I can use to
So you develop a kernel driver and don't know about cron?
Vilmos
I just wrote something about this in the FAQ:
http://www.daimi.au.dk/~kasperd/comp.os.linux.development.faq.html#memleak
Comments are welcome.
--
Kasper Dupont -- der bruger for meget tid paa usenet.
For sending spam use mailto:aaa...@daimi.au.dk
Their business was zero and it was shrinking.
A simpler solution is a script, after all this is just for debug right?
while [ 1 ]
do
cat /proc/meminfo >> /tmp/memlog.txt
echo " *********** DELIMITER *************" >> /tmp/memlog.txt
sleep 600
done
/* untested */
--
Randy Howard _o
2reply remove FOOBAR \<,
______________________()/ ()______________________________________________
SCO Spam-magnet: postm...@sco.com