General Info:
Hardware memory checker is a memory checker utility that provides memory allocation and release functionality. It uses the memory paging system to allocate a guard page after each page of memory to provide a hardware boundary that can detect memory overflows. This allows for immediate detection of buffer overflow error conditions.
There are many other memory checker programs in existence, you may wonder why one more. This Hardware Memory Checker provides a combination of features that I have not found in other memory checkers.
- it uses the hardware paging system for immediate error detection (most other memory checkers look for modified memory, this means detection occurs later)
- it is very fast compared to other hardware memory checkers because it makes fewer changes to the paging tables (several orders of magnitude faster than libefence)
- it can track the original release location when debugging duplicate free problems
- it is designed for large scale integration with the ability to call user defined fail functions
The speed and robustness of this memory checker make it suitable for limited field use which can be very helpful for finding problems that only seem to occur in the field.
This memory checker also includes many features that one would expect to find in a memory testing library including:
-mismatched malloc / delete / delete[]
-0 byte memory allocations
-leak detection
Usage:
Hardware memory checker can be used simply by linking with an existing program though more detailed source and line number messages can be generated if the header files are included. For C++ include hmccpp.h, for C include hmc.h.
Hardware memory checker is configurable. There are a number of options that affect the speed vs. coverage balance as well as options that determine what should be checked. This can be done in the registry on windows, in a HMC file on unix, or inside the program with which it is linked by redefining either:
void _HMC_InitDefaults(struct _HMC_MemorySettings * memorySettings);
void _HMC_InitSettings(struct _HMC_MemorySettings * memorySettings);
As Hardware Memory Chccker defines its own copy of malloc, free, and other memory functions, linking may require an option to allow redefining symbols.
On windows this has required /FORCE:MULTIPLE
On linux this has required -Xlinker –allow-multiple-definition
Installation:
In the lib directory, there is a makefile for linux and a project file for windows.