Features

MIWM features

miwm has the following features:

If you don't like minimalist aesthetics, miwm is probably not the tool for you. Many other choices are available through this website.

Memory Leak Detection

miwm includes a very simple, general purpose memory leak checker and debugger. It is contained in the two files mlchckr.h and mlchckr.cc.

Basically, mlchckr overloads new and delete. It maintains a vector of memory blocks. Each new allocation adds a block, and each deallocation removes it. It detects double-deletes.

It has four meaningful levels of debugging:

The API is simple:


The purpose of FirstSuspectBlock is to enable you to set a breakpoint that will stop exactly where the leak originated, without too much tedium. First you run your program with Level 2 checking, and pick a leak to fix. But when you have a memory leak on the 42,719-th block allocated, it is really tedious to step through 42,718 allocations to get to where the bad one happened. The solution is to set the first suspect block to 42719, set the breakpoint, and on the next run it will hit the breakpoint only when the bad allocation happens. Usually, for well-structured code, seeing where it was allocated is enough to make it obvious how to fix the leak.

Clearly, the above process depends on repeatability. To help that, a simple random number generator is included in miwm. It is completely contained in rng.h and rng.cc. It produces reasonable sequences, with complete repeatability. If you want true randomness, use /dev/random ! Better PRNG's exist, but this is a good compromise of randomness, simplicity, and repeatability.

The primary problem with mlchckr is that it stores the memory blocks in a vector. This means N^^2 time to handle N items, which can get to be a noticable penalty for programs that hold lots of data in memory at once, like A* search. A newer version, called ml, uses a splay tree for N lg(N) performance, and negligable performance penalty.