I am using Doug Lea’s dlmalloc memory allocator. However I get segmentation when I use that. If I use the normal malloc my program runs fine. I remember I once read that you need to first call some initialization function for dlmalloc to work, but I can’t remember now which function. I have tried to look at the comments to figure out which function, but still can’t find it.
I am using Doug Lea’s dlmalloc memory allocator . However I get segmentation when
Share
From the comments in the source code of the allocator:
You need to compile the library with
USE_LOCKS, otherwise you may see crashes.Another possibility is that your program exhibits undefined behavior that does not lead to consequences with the regular
malloc. For example, it might write one byte past the allocated area somewhere, but that byte could be part of a memory chunk that is a few bytes larger than what you have requested. Use valgrind to check your program for memory errors with "regular" malloc before linking it with the custom allocator.