lsan_stats.h - mhahnFr/LeakSanitizer GitHub Wiki
With the functions in this header, all statistics about the allocations can be queried.
extern bool __lsan_printStatsOnExit
[!WARNING] Deprecated since version 1.7: This option is no longer supported.
Will be removed in version 2.
Defaults to false
. Setting it to true
will cause the sanitizer to print the statistics upon normal
termination of the program.
size_t __lsan_getTotalMallocs()
Returns the total count of allocations ever registered by the sanitizer.
size_t __lsan_getTotalBytes()
Returns the total count of allocated bytes ever registered by the sanitizer.
size_t __lsan_getTotalFrees()
Returns the total count of freed objects that were previously registered by the sanitizer.
size_t __lsan_getCurrentMallocCount()
Returns the count of the currently allocated objects registered by the sanitizer.
size_t __lsan_getCurrentByteCount()
Returns the count of the currently allocated bytes registered by the sanitizer.
size_t __lsan_getMallocPeek()
Returns the highest count of objects in the heap at the same time.
size_t __lsan_getBytePeek()
Returns the highest count of bytes in the heap at the same time.
bool __lsan_statsAvailable()
[!WARNING] Deprecated: since version 1.5, please refer to
__lsan_statsActive
.
Will be removed in version 2.
Returns whether the memory statistics can be queried safely. If it returns false
, but the
memory statistics are queried regardless, the sanitizer might crash.
[!NOTE] Added in version 1.1.
bool __lsan_fStatsAvailable()
[!WARNING] Deprecated: since version 1.5, replaced by
__lsan_statsActive
.
Will be removed in version 2.
Abbreviation for __lsan_fragmentationStatsAvailable()
.
[!NOTE] Added in version 1.2.
bool __lsan_fragStatsAvailable()
[!WARNING] Deprecated: since version 1.5, replaced by
__lsan_statsActive
.
Will be removed in version 2.
Abbreviation for __lsan_fragmentationStatsAvailable()
.
[!NOTE] Added in version 1.2.
bool __lsan_fragmentationStatsAvailable()
[!WARNING] Deprecated: since version 1.5, replaced by
__lsan_statsActive
.
Will be removed in version 2.
Returns whether the memory fragmentation statistics can be queried safely. If it returns false
,
the statistics can be queried regardless without crash, but they might be wrong.
[!NOTE] Added in version 1.2.
void __lsan_printFStats()
Abbreviation for __lsan_printFragmentationStats()
.
[!NOTE] Added in version 1.2.
void __lsan_printFragStats()
Abbreviation for __lsan_printFragmentationStats()
.
[!NOTE] Added in version 1.2.
void __lsan_printFragmentationStats()
Prints the statistics of the memory fragmentation. The bar has a size of 100 characters, it can be
adjusted by using __lsan_printFragmentationWithWidth(size_t)
. The output stream defined by
__lsan_printCout
is used for the printing. The byte amounts are printed human-readable if
__lsan_humanPrint
is set to true
.
This function already checks for the availability of the memory statistics using __lsan_statsActive
and guarantees to not crash the program, even in the case th memory fragmentation statistics are unavailable.
[!TIP] Example:
Stats of the memory fragmentation so far: 97587 objects in the heap, peek 120463, 415640 deleted objects. 5.49 MiB currently used, peek 7.25 MiB. [=...................................................=....======.....====.==========================.] of 13.55 MiB total 97587 objects currently in the heap, peek 120463 objects. [=.=.=.=..=.===..============.........=========.=====================================================] of 122854 objects total
[!NOTE] Added in version 1.2.
void __lsan_printFStatsWithWidth(size_t)
Abbreviation for __lsan_printFragmentationStatsWithWidth(size_t)
.
[!NOTE] Added in version 1.2.
void __lsan_printFragStatsWithWidth(size_t)
Abbreviation for __lsan_printFragmentationStatsWithWidth(size_t)
.
[!NOTE] Added in version 1.2.
void __lsan_printFragmentationStatsWithWidth(size_t)
Prints the statistics of the memory fragmentation. The size of the bar is specified by the given argument.
The output stream defined by __lsan_printCout
is used for the printing. The byte amounts are printed
human-readable if __lsan_humanPrint
is set to true
.
This function already checks for the availability of the memory fragmentation statistics using __lsan_statsActive
and guarantees to not crash the program, even in the case the memory fragmentation statistics are unavailable.
[!TIP] Example with a width of
65
:Stats of the memory fragmentation so far: 97587 objects in the heap, peek 120463, 415640 deleted objects. 5.49 MiB currently used, peek 7.25 MiB. [=....................................====...=====================] of 13.55 MiB total 97587 objects currently in the heap, peek 120463 objects. [===.=..=..========......======.==================================] of 122854 objects total
[!NOTE] Added in version 1.2.
void __lsan_printStats()
Prints the statistics of the allocations. The bar has a size of 100 characters, it can be adjusted by
using __lsan_printStatsWithWidth(size_t)
. The output stream defined by __lsan_printCout
is used for the printing. The byte amounts are printed human-readable if __lsan_humanPrint
is set to true
.
This function already checks for the availability of the memory statistics using __lsan_statsActive
and guarantees to not crash the program, even in the case the memory statistics are unavailable.
[!TIP] Example:
Stats of the memory usage so far: 297 objects in the heap, peek 661, 485 deleted objects. 7.72 MiB currently used, peek 7.72 MiB. [====================================================================================================] of 7.72 MiB peek 297 objects currently in the heap, peek 661 objects. [=============================================.......................................................] of 661 objects peek
void __lsan_printStatsWithWidth(size_t)
Prints the statistics of the allocations. The size of the bar is specified by the given argument. The output
stream defined by __lsan_printCout
is used for the printing. The byte amounts are printed
human-readable if __lsan_humanPrint
is set to true
.
This function already checks for the availability of the memory statistics using __lsan_statsActive
and guarantees to not crash the program, even in the case the memory statistics are unavailable.
[!TIP] Example with a width of
65
:Stats of the memory usage so far: 299 objects in the heap, peek 661, 565 deleted objects. 7.72 MiB currently used, peek 7.72 MiB. [=================================================================] of 7.72 MiB peek 299 objects currently in the heap, peek 661 objects. [==============================...................................] of 661 objects peek