Tuesday, 7 January 2020

Deleaker Review – finding memory leaks in C++ and Delphi

Deleaker https://www.deleaker.com
From $99

Memory leaks are some of the trickiest things to track down when you are writing programs. Somewhere you allocate a chunk of memory and then later on, that memory isn’t freed when it’s no longer needed. Small memory leaks might not be a problem but when a program allocates huge amounts of memory, you can run into trouble. In a long programming career, I’ve seen people spend weeks trying to track down obscure memory problems. It’s usually quite easy to track down problems that cause your program to crash every 10 minutes. But once every ten days? Not so easy at all.

Of course, in modern garbage collected languages like C# and Java, memory leaks are no longer a problem – or are they? It’s certainly the case that garbage collection makes life a lot easier. In general, you don’t have to bother about freeing up memory – it’s done automatically. However, you can still get problems if you call system APIs or libraries written in another language where memory is not managed.

If you have (or think you have) a memory leak problem, then a tool to track down the source of the leak might be  useful. One such tool is Deleaker. This comes with a 14 day trial period where you can use the full functionality of the tool. Deleaker helps you find and fix memory leaks in your C, C++ or Object Pascal programs developed using either Microsoft’s Visual Studio or Embarcadero’s RAD Studio/Delphi.

This is Deleaker’s own video showing integration with RAD Studio.

When installed, Deleaker can either be run from a menu item in your chosen IDE or it can be run as a standalone application so that it is available on a PC without the IDE installed. The licence allows a single user to run Deleaker on multiple PCs which is convenient if you need to use it both on your desktop computer and also on a laptop.

Here I have docked Deleaker into the Delphi IDE. You can keep its window ‘free-floating’ if you prefer.
Deleaker has a very nice integration with Visual Studio and Delphi and most of the time it works smoothly though it did crash Visual Studio on one occasion. You can also use it in  standalone mode from the console – Deleaker attaches itself to the process you specify so as to perform its magic.

We tried it out on some very simple programs with a couple of memory leaks and it worked great. At the end of the run, Deleaker will identify the leaks and indicate the source of the leak. However, it doesn’t (and can’t) tell you where you should have freed the memory. But it’s a good start and with some extra coding diagnostics, you should be able to track down memory leaks reasonably easily.

In my experience, though, simple memory leaks are not the huge problem that they are sometimes made out to be. First, from my own experience early on in my programming career seeing other programmers get in real deep trouble, I’ve been absolutely fanatical about memory allocation. Because of that I’ve never had a serious problem. The other memory problem that Deleaker can’t help with is where you have accidentally reused some freed memory: you have two pointers to the same memory address and you’ve forgotten about the second pointer when you called free on the first. These can be very tricky indeed to track down.

But where Deleaker does score is keeping track of system resources such as GDI device contexts, handles and the like. It is surprisingly easy to lose track of these because they tend to exist for a long time in the program and the effects of not freeing handles are not obvious – you don’t see memory creeping up and your program slowing down dramatically until the whole of Windows starts to seize up.

Here Deleaker has produced a report of some leaks in a Visual Studio C project.
Overall, Deleaker is a nice, simple tool that fits in well with Visual Studio and Delphi and makes tracking down memory leaks much easier. It’s not a cure-all for poor programming practice, though. If you have a badly written program, it will tell you that you have a leak and the line that allocated the memory, but it’s up to you to find out where you should have freed it.

At the end of the day, while you have been careful about memory allocation and resource tracking (and in my case paranoid about it) – how you do you know that you have no memory leaks? Without something like Deleaker you won’t - and here Deleaker does shine in acting as a quality check keeping track of memory and non-obvious system resources: it’s always a lot cheaper to fix bugs before releasing software and any tool such as Deleaker that helps produce bug free software is well worth the money.

For this review Dermot Hogan reviewed Deleaker for Visual Studio (Huw Collingbourne tested it with Delphi)

Tuesday, 10 December 2019

Program a Delphi Collapsible Outliner - Deleting Nodes

If you've been following my YouTube series on using Delphi to create a Collapsible Outliner, you'll be interested in the latest lesson which explains how to delete nodes (and child nodes).

The source codes for all the projects in this series is available from the Bitwise Books web site. Just sign up for our newsletter and we'll send you the download links: http://www.bitwisebooks.com

Friday, 29 November 2019

Learn To Program A Text Adventure Game

Looking for the perfect Christmas present for the programmer who “has everything”?  May I suggest my newest book, The Little Book Of Adventure Game Programming.

The Little Book Of Adventure Game Programming provides a step-by-step guide to creating a game in C#, which is one of the most important languages on Windows and is also available on macOS and Linux. The programming principles and techniques explained in the book can also be used to write adventure games in other languages such as Java, Ruby or Object Pascal. Short examples (source code also available for download) are provided in those languages. As well as teaching adventure games specifically, this book can also be used as a tutorial to writing C# programs. It covers all the most important features of the C# language.

This book explains...

  • How to write Interactive Fiction (IF) games
  • Creating class hierarchies
  • How to create a map of linked 'rooms'
  • Moving the player around the map
  • Adding treasures to rooms
  • How to take and drop treasures
  • Putting objects into containers (sacks, treasure chests etc.)
  • Using lists and dictionaries
  • Overridden methods
  • Overloaded methods
  • How to save and load games
  • Designing a game with a user interface
  • Designing a command-line game to run at the system prompt
  • ...and much more

Available in paperback or for Kindle from Amazon (US):  https://www.amazon.com/dp/1913132080 and (UK): https://www.amazon.co.uk/dp/1913132080

Tuesday, 26 November 2019

Customize the Colours of the Visual Studio Code Terminal

I love Microsoft's free multi-language programming editor but I've never found the perfect colour scheme because I'm a traditionalist and like the Terminal to have a black background with green text. In fact, you can change the Terminal to use any colours you like - as I show in this video.

Tuesday, 12 November 2019

Learn to Program Ruby FREE

I'm starting a new Ruby programming series on YouTube. The first video went online today. More to follow soon. Be sure to subscribe to my YouTube channel to get notification of new lessons.

Monday, 11 November 2019

Arrays, Addresses and Pointers in C Programming

What's the difference between this:

char s[] = "Hello";

and this...?

char *s = "Hello";

Aren't they just two ways of doing the same thing? That is, of assigning the string "Hello" to the string variable s? Well, no. In fact, these two assignments are very different things. If you have moved to C from another language such as Java, Python, C# or Ruby, making sense of arrays, strings, pointers and addresses is likely to be one of the biggest challenges you'll face. Here's a video I made that should help out.



For a more in depth guide to C programming, see my book, The Little Book Of C:
Amazon (US): https://amzn.to/2RXwA6a
Amazon (UK): https://amzn.to/2JhlwOA

For a full explanation of pointers, see The Little Book Of Pointers:
Amazon (US): https://amzn.to/2LF2aVb
Amazon (UK): https://amzn.to/2FViSvS

Friday, 8 November 2019

Use the Delphi TreeView to Program a Collapsible Outliner

Here is the latest lesson on creating an outlining tool with Object Pascal and Delphi:


Be sure to subscribe to my YouTube channel in order to be notified whenever a new lesson is uploaded: https://www.youtube.com/BitwiseCourses?sub_confirmation=1