|
|
|
|
|
by hedora
2249 days ago
|
|
I’ve had good luck (in C++) replacing the underlying memory allocator with one that tracks leaks by allocation type (which is fast enough for production use). This can be done in C, but the calling code has to spell malloc and free differently. In debug mode, configuring malloc to poison (and add fences) on allocation and free finds most of the remaining things. These techniques tend to have much lower runtime overhead than valgrind (2-digit percentages vs 5-10x), so they can be left on throughout testing and partially enabled in production. They find >90% of the memory bugs that I write (assuming valgrind finds 100%). YMMV. |
|