Welcome to Diamond
Diamond is a post-mortem memory debugger and profiler. It is composed of two parts:
- a module, which should be imported before any other modules in the project to be debugged
- a memory log analyzer, which allows inspecting generated memory logs
The module logs all memory operations to a file, as well as periodic memory snapshots (before garbage collects). Some logging options are configurable.
Diamond aims to facilitate debugging memory leaks (data referenced by bogus pointers), memory corruption and other problems. It was written for D1 (both Phobos and Tango), D2 support is untested at best.
The project is not yet complete, but still usable. The log file format may change as development continues.
Runtime module features:
- logs all memory events, with timestamps and call stacks
- exports C functions, allowing debuggee to make memory maps or snapshots at any time, as well as log text comments
- has optional memory debugging features, like checking free calls and stomping on deallocated memory
Log analyzer features:
- uses map files to display symbols in call stacks
- can seek through the log file, allowing to examine the application state at different points in time
- can display "top allocators" - call stacks that allocated most bytes
- can filter memory events by address range
- can display a visual "memory map" (useful for quickly finding large areas the GC shouldn't be scanning for pointers)
- can search for references (pointers) to a certain memory range
- can dump a region of memory to screen
Limitations:
- limited support for multi-threaded programs
- limited by design to 32-bit architectures
Future plans:
- better documentation
- more type information (by hooking higher-level allocators)
- dumping data segment and thread stacks (currently only the heap is dumped)
- more runtime library options
- better multi-threaded support
- use of CodeView instead of map files to allow symbolic examination of objects
- possibly, more means to detect/debug memory corruption
- possibly a major revision as a replacement runtime, rather than a normal module
How to use
- Copy diamond.d to your project's directory
- Adjust options defined at the top of diamond.d
- Add import diamond; before other imports in your project's main module
If memory event logs are required:
- Enable .map generation, then recompile and run your project as usual
- When the program terminates, run the memory analyzer
Otherwise:
- Recompile and run your project as usual
For correct stack traces, you'll need to rebuild Phobos with symbols.
Download
Project Information
| Name | Diamond |
| Category | Development Tools |
| Status | 4 - Beta |
| Short Description | D memory debugger |
| Long Description | |
| Forum | /forums/viewforum.php?f=191 |
| Home Page |
