Skip navigation

I was facing memory leak issue with an application (application contains 12 .c file and each .c file contains approx 4000 to 7000 lines of code), So one solution is to debug the application with ‘valgrind’ and find out memory leak problem, but I was wondering about different solution than ‘valgrind’ tool. Since I wanted to fix the memory leak issue
with different method so I started exploring the area.

I have used the ‘top’ command in Linux and I know it gives complete snapshot of a System at given interval time. So I started looking for parameter which gives me physical(actual) memory used by the process/application, and I come to know about Resident set size (From wikipedia, “Resident set size is is the portion of a process’s memory that is held in RAM”) Now all I have to write and application that print the ‘RSS’ value.

Now that gives a birth to ‘Memwatch’ ( ‘Memwatch’ print total memory and actual physical memory usage of a process at certain interval.

So to trace the memory leak in application, I start the application with gdb and holds a break point at ‘main’ and I started execution function by function, while step over to the function, I constantly monitor the ‘Memwatch’ output and at one point I found that significantly memory has increase, so I debug that function and found that huge memory leakage was in the function (because usage of strdup and malloc without free implementation).

In short this is another short implementation of ‘top’ command but you can use the function ‘CheckUsage’ in your application and call it before and after the function and it will print the memory usage at begin and end of function, but this is lazy and another way to find out. Another solution is to achieve the same thing is with the mix of ‘top’, ‘awk’ and other Linux command.

‘Resident Set Size’ value help me to find out the memory leak and I wrote a small application on top of that, and I decided to share it with the world.

If you like this post, do ping me on Twitter at @suresh_kanzaria

Happy Hacking !




I encountered libtool version mismatch error while building Buildroot for ARM architecture on Ubuntu 32bit machine.

Below command help me to resolve this issue. I moved to the package director and apply the command. After this buildroot building process start smoothly.

‘autoreconf -vfi’

Hope this will save your time.

See you in next post. 🙂

Mothers Day

There is no words to express Mother’s Love !!

Happy Mother’s Day.

*That’s little cute Boy is my Nephew – Saket. 🙂


A few days back, I was replying my friend via tweet. He had some problem with regarding support with a company which provides cloud hosting, so he was asking about the proper support via twitter, I seen his tweet and immediately tweet again to the same company.

Now an Interesting things comes to my mind, Why not Twitter save the all mentions (‘@’) which we replied, so that next time If we want to tweet those people, they appear in our list when we start typing. In short there must me some mechanism to store all mentions so that in future those contact are ready when we want to connect with him further.

I am using twitter in my android phone and Macbook, so I am not sure if this functionality provided by other Apps or not, But it will be great If I got this features in my android phone and Macbook.

Hope Twitter guys will implement this features one day and tweet me back. 🙂