# Discovering memory leaks in device drivers?



## peterlaursen (Oct 20, 2011)

Hi everyone,

I have just finished a rough draft of my Braille device driver.(See most of my previous threads in this forum)

It works on both 8.2-RELEASE and 9.0-BETA3. I have a small problem:
When I detach my hardware, I need to deallocate some memory. I use character devices to write to my hardware and the character devices have two fields that one can use for private, instance-specific data. One of these fields has been used to keep an index number (int32). Memory is allocated when hardware is attached.

When I detach my hardware, the system froze when I tried to free the memory on FreeBSD 9.0-BETA3. On FreeBSD 8.2-RELEASE, no such thing happened. If I uncommented the line freeing memory, the device was attached properly and the system did not freeze on any of the systems.
This leads me to suspect that my driver now has a very small memory leak. How can I test for this or get some output confirming it?

I look forward to any replies.

All the best,

Peter.


----------

