Pages

Friday, October 23, 2015

Identify Memory Leaks in Visual CPP Applications

A friend of mine told me about this useful tool to identify hard to find memory leaks in Visual C++ applications. Visual Leak Detector (VLD) is an easy to use memory leak detection system. The installation package can be downloaded from here.

After installation, it can be used with any C/C++ project simply by adding the following line to the code:


#include <vld.h>



When the program is executed under the Visual Studio debugger, Visual Leak Detector will output a memory leak report of the executed segment of the code, at the end of the debugging session. If memory leaks are detected, this report will point to the exact locations in the code segment, which allocated the leaked memory block.

The header file can be easily isolated from rest of the source codes by guarding it with the pre-processor directive block. It can be made further user friendly by defining a separate Visual Studio build configuration for VLD. The steps are as follows.

Monday, October 19, 2015

Debugging with GDB


As discussed here, "printf debugging" is the most straight forward way of figuring out what is happening under the hood, during run time of an C / C++ program. But this approach is a bit time consuming as the code has to be modified and recompiled according to the debugging scenario. A more flexible way is to use a separate debugger program. GDB: The GNU project debugger stands at the top of this list. 

The general practice is to use GDB with an Integrated Development Environment as eclipse, which greatly simplifies the debugging process. However, to debug a program executing within a device which does not have a graphical user interface (for instance an embedded Linux system with a serial console), GDB on a console is a pretty useful option. 

Tuesday, March 11, 2014

Preprocessor to control printf debugging

A fundamental way of debugging an application, especially developed using  C / C++ programming languages is "printf debugging". i.e. To dump a message on to console output with some variables.

However, including too many "printf debugging" statements can hinder the performance of an application. Therefore, it is important to include a mechanism to automatically remove all such debugging statements. The easiest way to achieve this is through conditional compilations.

One straight forward way is to wrap the printf statements within a preprocessor directive as follows.


#ifdef _DEBUG
    printf("Debug message\n");
#endif


This approach adds too much clutter into the source code. Therefore, I was looking for a elegant solution to this fundamental problem and came across the following code block.

Saturday, February 22, 2014

Download YouTube videos with VLC Media Player

Saving  YouTube media files on the computer for offline viewing is easier once we have made all the configurations in the VLC media player as given here.
  1. Under Tools menu, select Codec Information (Ctrl + J).
  2. Copy the URL given as Location (As highlighted below), in the Current Media Information popup window.  

Friday, February 14, 2014

Play YouTube videos with VLC Media Player

I was searching the internet for a way to play YouTube videos with special audio and video effects like color correction, hue & contrast adjustment and other special effects. It was quite a surprise to learn that the solution was within my fingertips all the time. 

Countless times, videos have been viewed using VLC media player, simply by double clicking the file on Windows Explorer. Therefore, the Media menu rarely attracted attention and the solution was silently waiting there to be explored.

Here are the simple steps.

Friday, February 7, 2014

FTP made easy with LFTP

I was looking for a decent FTP client program to perform a relatively complex series of file transfers using a Linux shell script and came across LFTP.

LFTP is a freely available file transfer program which allows FTP, HTTP and a number of other connections to a remote host.

A few of the evaluation commands I tried with LFTP are listed here as a future reference to my self as well as anyone looking for quick examples.

Monday, February 3, 2014

Virtual WiFi hotspot with Windows 7

I had a problem with connecting multiple mobile devices to the wireless router as it had reached the maximum number of nodes. I was looking for a way to convert my laptop to a virtual WiFi hot spot and connect the mobile devices to the internet by sharing the LAN internet connection with the virtual WiFi adapter. 

A bit of Googling reviled a number of third party apps which can create a virtual WiFi. But with further reading, I learnt that this is a built in feature of Windows 7 operating system. A few configurations in the Windows "Network and Sharing Center" or a few commands on the Command Prompt do the trick.