currently I am trying to hunt down a memory leak in our software. Using ps I found that the software leaks about 152kB in 15 hours. There is plenty of source code involved so “manually” looking for the leak would be very time consuming.
I found an interesting thread on the QNX website:
qnx.com/developers/docs/mome … g/hat.html
Unfortunately, the debug library <malloc_g.h> is not part of our Watcom installation and seems to be available for QNX6xx only.
Any help or ideas how to debug the memory consumption on QNX4.25 would be greatly appreciated.
I use a set of custom alternate functions for memory allocation that allows me to detect memory leak, buffer overrun and underrun, etc. You would have to rename all your fonction call though.
Tell me if you are interested, I can post it here.
If you look on the web you will find plenty of sources that does just that.
thanx for your quick reply (and your offer). Running further tests today, I am tempted to think that the leak is in one of the SQL database calls. Reading that code - to my surprise - there are no “mallocs” nor “frees” in there. So I guess I’ll start there, dig a little deeper and optimize the code a bit. It looks like I can do without additional debug code…
Just found the leak: Back then the programmer used the function strdup() instead of strcpy() in 1 (!) place and never freed the implicitly mallocated memory. Now that I changed the function to strcpy() the memory hogging is all gone
As part of the memory library I use, there is a replacement for strdup as well