Repository navigation
Conversation
Owner
|
This debug allocator was an old trick that predated valgrind and AddressSanitizer. It's a good first-order check & balance to reveal memory leak. I think it doesn't hurt to keep it. This is only used by the developers if needed. The users don't see it, because they won't set DEBUGlevel>=1 |
Contributor
Author
|
I think it clutters the code. Not by much. I still think pointing people to modern tools is the better way. It is your call, if you close this merge request, I have no hard feelings. Even Claude Code pointed out that I split the changes into two merge requests is a good idea, as "the maintainers might want to discuss" the changes of this merge request... |
Owner
|
I suggest to keep this PR open. |
CHECK_MALLOC printed the running byte count kept by the debug allocator (DEBUGlevel >= 1). The calls are only compiled in debug builds and the information they print is better obtained from AddressSanitizer / LeakSanitizer or Valgrind. Remove the calls in preparation for dropping the debug allocator.
With DEBUGlevel >= 1, superlu_malloc()/superlu_free() prepended a
size header to every block to count allocated bytes and catch double
frees. This is fully covered by AddressSanitizer, LeakSanitizer and
Valgrind, which additionally detect out-of-bounds accesses and do not
need a special build of the library. The header also shifted every
returned pointer by sizeof(double), weakening malloc's alignment
guarantee (16 bytes on x86-64) in debug builds only.
superlu_malloc()/superlu_free() are now always thin wrappers around
malloc()/free(). The CHECK_MALLOC macro, which relied on the debug
counter superlu_malloc_total, and a disabled USER_MALLOC variant that
filled new memory with 0x0F (MemorySanitizer and Valgrind find
uninitialized reads) are removed as well. USER_MALLOC/USER_FREE can
still be defined to plug in a custom allocator.
To check for memory errors and leaks, build with AddressSanitizer
(supported by GCC and Clang) and run the tests:
cmake .. -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_FLAGS="-fsanitize=address -fno-omit-frame-pointer"
make
ctest --output-on-failure
or run a program under Valgrind, e.g.,
valgrind --leak-check=full EXAMPLE/dlinsol < ../EXAMPLE/g20.rua
gruenich
force-pushed
the
feature/remove-memory-debugging
branch
from
October 23, 2026 05:04
c22c096 to
5b58be2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Drop the DEBUGlevel debug allocator
With DEBUGlevel >= 1, superlu_malloc()/superlu_free() prepended a
size header to every block to count allocated bytes and catch double
frees. This is fully covered by AddressSanitizer, LeakSanitizer and
Valgrind, which additionally detect out-of-bounds accesses and do not
need a special build of the library. The header also shifted every
returned pointer by sizeof(double), weakening malloc's alignment
guarantee (16 bytes on x86-64) in debug builds only.
superlu_malloc()/superlu_free() are now always thin wrappers around
malloc()/free(). The CHECK_MALLOC macro, which relied on the debug
counter superlu_malloc_total, and a disabled USER_MALLOC variant that
filled new memory with 0x0F (MemorySanitizer and Valgrind find
uninitialized reads) are removed as well. USER_MALLOC/USER_FREE can
still be defined to plug in a custom allocator.
To check for memory errors and leaks, build with AddressSanitizer
(supported by GCC and Clang) and run the tests:
cmake .. -DCMAKE_BUILD_TYPE=Debug
-DCMAKE_C_FLAGS="-fsanitize=address -fno-omit-frame-pointer"
make
ctest --output-on-failure
or run a program under Valgrind, e.g.,
valgrind --leak-check=full EXAMPLE/dlinsol < ../EXAMPLE/g20.rua