Documentation

About

MemTest (which obviously is short for Memory Tester) is a memory leak/corruption detection system for C++/C programs. It is a cpp file and a header file which, when included in other source code files, will track all the usage of memory allocations/deallocations to tell the user if there were any memory leaks or memory corruptions within the code.

It does this by tracking all calls to new/delete/malloc/realloc/calloc/free. Of course, this adds a minor slowdown to whatever program it is being used in, but the slowdown is minor, and far worth the benefit. I'm using it in my own programs and am quite pleased.

Features

To Use

To use simply #include memtest.h at the beginning of each cpp file in your project. The #include should be after all other includes.

For example:

Functions

Most functions are built in and well documented within memtest.cpp. You may want to use the following functions in addition to the automatic ones.

void DumpMemTestReport(const char *filename, bool stats=true, bool leaks=false, bool mem=false);
This function is used to dump a memory report to a filename. This is done at the end of the program if the appropriate flag is set in memtest.cpp. It can be done in the middle of the application running here. If stats=true it will about program statistics. If leaks=true, it will output all current memory leaks (which will be a great deal if this is called in the middle of the program). If mem is true, it will do a hex memory dump of all allocated memory on the heap. This may take a large amount of hard drive space to do (so only use it if you need it).
unsigned int getCurrentAllocBytes()
Returns the number of bytes currently allocated in the program.
unsigned int getMaximumAllocBytes();
Returns the maximum number of bytes allocated by your program at any one time. This can be used as a system to accurately detect how much memory on the heap your program uses.
unsigned int getTotalAllocBytes();
Return the total bytes allocated throughout the duration of the program. This number will always be greater or equal to the number returned by getMaximumAllocBytes()

License

This software is licensed under the LGPLv3

MemTest is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

MemTest is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with MemTest. If not, see <
http://www.gnu.org/licenses/>.

Download

VersionRelease DateFormats
0.15/20/2008zip | tar.bz2

Versions

5/25/08 - Version 0.1
Released with basic memory leak detection and corruption detection.

Contact

If you have a question please post it on the
RedGalaxy QA website. You can contact me by sending an email to .