Short: Library to help detect memory leaks Author: morgoth6@box43.pl (Marcin 'Morgoth' Kurek) Uploader: morgoth6@box43.pl (Marcin 'Morgoth' Kurek) Type: dev/c Version: 0.4 Architecture: MorphOS Introduction: ============== This library was a quick project that helped me to find a ugly memory trash in one of my projects, but I think it can be handy not only for me. It helps to detect: - Memory leaks - Mismatched free operations (Wrong size or type) - Memory trashing (both underflows and overflows) [optional] It supports following functions: - AllocMem - FreeMem - AllocVec - FreeVec - AllocTaskPooled - FreeTaskPooled - AllocVecTaskPooled - FreeVecTaskPooled - AllocVecDMA - FreeVecDMA - AllocMemAligned - AllocVecAligned - CreatePool - DeletePool - FlushPool - AllocPooled - FreePooled - AllocVecPooled - FreeVecPooled - AllocPooledAligned Following ANSI functions are wrapped to MorphOS Alloc/FreeVecTaskPooled() - malloc - calloc - free Also it contain some additional memory related functions to allocate memory from pool with clear: - AllocPooledC - AllocVecPooledC - AllocPooledAlignedC Usage: ======= First make sure that resources.h is included in all files of your project as a last include file. Also the PrepareMemTrack() need to be called at begining of the main() function and EndMemTrack() at the end. Now you can controll the memtrack by defining MEMTRACK. If not defined the libresources.a is fully transparent, then enabling/disabling of libresources.a do not require any modifications in the source code just def or undef of the MEMTRACK. Output is printed in to the log. Look in to the test/ directory to see some examples of usage and in to resources.h to find out the supported flags for PrepareMemTrack() Example: ========= A example output can look's like that (from test/test1.db): [EE] test1: Free area 0x225909a0 with wrong size 8192, should be 4096 [Called test1.c:35/main() Allocated test1.c:20/main()] [EE] test1: There is still 2 allocations on CleanupMemTrack_Memory() -> Verify allocation list for 'test1' ... -> Verified allocation list for 'test1' -> Dump allocation list for 'test1' ... <0x225909a0> Size 4096 bytes Type 0x1 [test1.c:20/main()] <0x225fdee0> Size 8192 bytes Type 0x1 [test1.c:21/main()] -> Dumped allocation list for 'test1' As you can see in a case of invalid free operation you will get a detailed information what was wrong and a position in the file where this invalid operation appear (And where the memory was allocated). History: ========= 0.2 - First released version 0.3 - Warn about deleting non empty pool only if RESF_WARNDIRTYPOOL is set 0.4 - Added support for malloc/calloc/free ansi functions Fixed smally typo in resources.h (This version is not compatible with older ones, please recompile to use it) ToDo: ====== Current version works fine for me then if you want something to be added or modified in in just let me know. Bugs: ====== Propably a lot. If you found one contact with me. Author: ========= Marcin 'Morgoth' Kurek (morgoth6@box43.pl) ThX: =====