talloc_debug(3)
π talloc_debug β the talloc debugging support functions π
okay bestie, welcome to talloc_debug(3), a page from the Library Functions Manual πΈ. this is the part of talloc where we stop just allocating stuff and start investigating it like the little detective main characters we are πβ¨
so basically: to aid memory debugging, talloc contains routines to inspect the currently allocated memory hierarchy. that's the whole vibe. we're peeking at the tree, no cap. π³
β¨ SYNOPSIS β¨
π Functions π
_PUBLIC_ void talloc_report_depth_cb (const void *ptr, int depth, int max_depth, void(*callback)(const void *ptr, int depth, int max_depth, int is_ref, void *private_data), void *private_data)β walk a complete talloc hierarchy πΆβοΈ_PUBLIC_ void talloc_report_depth_file (const void *ptr, int depth, int max_depth, FILE *f)β print a talloc hierarchy π¨οΈ_PUBLIC_ void talloc_report_full (const void *ptr, FILE *f)β print a summary report of all memory used by ptr π_PUBLIC_ void talloc_report (const void *ptr, FILE *f)β print a summary report of all memory used by ptr π_PUBLIC_ void talloc_enable_null_tracking (void)β enable tracking the use of NULL memory contexts π_PUBLIC_ void talloc_enable_null_tracking_no_autofree (void)β enable tracking the use of NULL memory contexts π_PUBLIC_ void talloc_disable_null_tracking (void)β disable tracking of the NULL memory context π_PUBLIC_ void talloc_enable_leak_report (void)β enable leak report when a program exits π¨_PUBLIC_ void talloc_enable_leak_report_full (void)β enable full leak report when a program exits π¨_PUBLIC_ void talloc_set_abort_fn (void(*abort_fn)(const char *reason))β set a custom abort"functionthatiscalledonseriouserror π_PUBLIC_ void talloc_set_log_fn (void(*log_fn)(const char *message))β set a logging function π_PUBLIC_ void talloc_set_log_stderr (void)β set stderr as the output for logs π₯οΈ_PUBLIC_ int talloc_set_memlimit (const void *ctx, size_t max_size)β_DEPRECATED_set a max memory limit for the current context hierarchy. this affects all children of this context and constrain any allocation in the hierarchy to never exceed the limit set. β οΈ
π Detailed Description π
to aid memory debugging, talloc contains routines to inspect the currently allocated memory hierarchy. that's it, that's the mission, and honestly? iconic. π
π¦ Function Documentation π¦
_PUBLIC_ void talloc_disable_null_tracking (void )
Disable tracking of the NULL memory context. this disables tracking of the NULL memory context. yes bestie, it does exactly what it says on the tin π«Ά
_PUBLIC_ void talloc_enable_leak_report (void )
Enable leak report when a program exits. this enables calling of talloc_report(NULL, stderr) when the program exits. in Samba4 this is enabled by using the --leak-report command line option. π¨
for it to be useful, this function must be called before any other talloc function, because it establishes a "null context" that acts as the top of the tree. if you don't call this function first, then passing NULL to talloc_report() or talloc_report_full() won't give you the full tree printout. so like. call it first. fr fr. π
here is a typical talloc report:
talloc report on 'null_context' (total 267 bytes in 15 blocks)
libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks
libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks
iconv(UTF8,CP850) contains 42 bytes in 2 blocks
libcli/auth/spnego_parse.c:55 contains 31 bytes in 2 blocks
iconv(CP850,UTF8) contains 42 bytes in 2 blocks
iconv(UTF8,UTF-16LE) contains 45 bytes in 2 blocks
iconv(UTF-16LE,UTF8) contains 45 bytes in 2 blocks
_PUBLIC_ void talloc_enable_leak_report_full (void )
Enable full leak report when a program exits. this enables calling of talloc_report_full(NULL, stderr) when the program exits. in Samba4 this is enabled by using the --leak-report-full command line option. π¨
and same deal as its sibling: for it to be useful, this function must be called before any other talloc function, since it establishes a "null context" that acts as the top of the tree. if you don't call this function first, then passing NULL to talloc_report() or talloc_report_full() won't give you the full tree printout. π
here is a typical full report:
full talloc report on 'root' (total 18 bytes in 8 blocks)
p1 contains 18 bytes in 7 blocks (ref 0)
r1 contains 13 bytes in 2 blocks (ref 0)
reference to: p2
p2 contains 1 bytes in 1 blocks (ref 1)
x3 contains 1 bytes in 1 blocks (ref 0)
x2 contains 1 bytes in 1 blocks (ref 0)
x1 contains 1 bytes in 1 blocks (ref 0)
_PUBLIC_ void talloc_enable_null_tracking (void )
Enable tracking the use of NULL memory contexts. this enables tracking of the NULL memory context without enabling leak reporting on exit. useful for when you want to do your own leak reporting call via talloc_report_null_full(); π§
_PUBLIC_ void talloc_enable_null_tracking_no_autofree (void )
Enable tracking the use of NULL memory contexts. this enables tracking of the NULL memory context without enabling leak reporting on exit. useful for when you want to do your own leak reporting call via talloc_report_null_full(); π§
_PUBLIC_ void talloc_report (const void * ptr, FILE * f)
Print a summary report of all memory used by ptr. this function prints a summary report of all memory used by ptr. one line of report is printed for each immediate child of ptr, showing the total memory and number of blocks used by that child. π
you can pass NULL for the pointer, in which case a report is printed for the top level memory context β but only if talloc_enable_leak_report() or talloc_enable_leak_report_full() has been called. otherwise it's giving nothing, bestie. π«₯
Parameters
ptrβ the talloc chunk.fβ the file handle to print to.
Example:
unsigned int *a, *b;
a = talloc(NULL, unsigned int);
b = talloc(a, unsigned int);
fprintf(stderr, "Summary of memory tree for a:\n");
talloc_report(a, stderr);
See also
talloc_report_full()
_PUBLIC_ void talloc_report_depth_cb (const void * ptr, int depth, int max_depth, void(* callback )(const void *ptr, int depth, int max_depth, int is_ref, void *private_data), void * private_data)
Walk a complete talloc hierarchy. this provides a more flexible reports than talloc_report(). it will recursively call the callback for the entire tree of memory referenced by the pointer. references in the tree are passed with is_ref = 1 and the pointer that is referenced. π²
you can pass NULL for the pointer, in which case a report is printed for the top level memory context β but again, only if talloc_enable_leak_report() or talloc_enable_leak_report_full() has been called. π
the recursion is stopped when depth >= max_depth. max_depth = -1 means only stop at leaf nodes. π
Parameters
ptrβ the talloc chunk.depthβ internal parameter to control recursion. call with0.max_depthβ maximum recursion level.callbackβ function to be called on every chunk.private_dataβ private pointer passed to callback.
_PUBLIC_ void talloc_report_depth_file (const void * ptr, int depth, int max_depth, FILE * f)
Print a talloc hierarchy. this provides a more flexible reports than talloc_report(). it will let you specify the depth and max_depth. ποΈ
Parameters
ptrβ the talloc chunk.depthβ internal parameter to control recursion. call with0.max_depthβ maximum recursion level.fβ the file handle to print to.
_PUBLIC_ void talloc_report_full (const void * ptr, FILE * f)
Print a summary report of all memory used by ptr. this provides a more detailed report than talloc_report(). it will recursively print the entire tree of memory referenced by the pointer. references in the tree are shown by giving the name of the pointer that is referenced. π
you can pass NULL for the pointer, in which case a report is printed for the top level memory context β but (say it with me now) only if talloc_enable_leak_report() or talloc_enable_leak_report_full() has been called. π«Ά
Parameters
ptrβ the talloc chunk.fβ the file handle to print to.
Example:
unsigned int *a, *b;
a = talloc(NULL, unsigned int);
b = talloc(a, unsigned int);
fprintf(stderr, "Dumping memory tree for a:\n");
talloc_report_full(a, stderr);
See also
talloc_report()
_PUBLIC_ void talloc_set_abort_fn (void(* abort_fn )(const char *reason))
Set a custom "abort" function that is called on serious error. the default "abort" function is abort(). π
the "abort" function is called when:
talloc_get_type_abort()fails- the provided pointer is not a valid talloc context
- when the context meta data are invalid
- when access after free is detected
Example:
void my_abort(const char *reason)
{
fprintf(stderr, "talloc abort: %s\n", reason);
abort();
}
talloc_set_abort_fn(my_abort);
Parameters
abort_fnβ the new "abort" function.
See also
talloc_set_log_fn()
talloc_get_type()
_PUBLIC_ void talloc_set_log_fn (void(* log_fn )(const char *message))
Set a logging function. π
Parameters
log_fnβ the logging function.
See also
talloc_set_log_stderr()
talloc_set_abort_fn()
_PUBLIC_ void talloc_set_log_stderr (void )
Set stderr as the output for logs. π₯οΈ
See also
talloc_set_log_fn()
talloc_set_abort_fn()
_PUBLIC_ int talloc_set_memlimit (const void * ctx, size_t max_size)
Set a max memory limit for the current context hierarchy. this affects all children of this context and constrain any allocation in the hierarchy to never exceed the limit set. the limit can be removed by setting 0 (unlimited) as the max_size by calling the function again on the same context. memory limits can also be nested, meaning a child can have a stricter memory limit than a parent. memory limits are enforced only at memory allocation time. stealing a context into a 'limited' hierarchy properly updates memory usage but does not cause failure if the move causes the new parent to exceed its limits. however any further allocation on that hierarchy will then fail. π
Warning β talloc memlimit functionality is deprecated. please consider using cgroup memory limits instead. π«
Parameters
ctxβ the talloc context to set the limit onmax_sizeβ the (new) max_size
πΈ Author πΈ
Generated automatically by Doxygen for talloc from the source code. π€β¨
and that's the whole page bestie, you ate that π
πΈ this was talloc_debug(3) from the talloc library, Version 2.0 β mwah, slay, go inspect those memory hierarchies, periodt ππ¦π
π¦ where this page comes from
- centos-stream 10: libtalloc-devel 2.4.4-100.el10 Β· LGPL-3.0-or-later
- fedora 43: libtalloc-devel 2.4.3-4.fc43 Β· LGPL-3.0-or-later
- fedora 43: libtalloc-devel 2.4.3-4.fc43 Β· LGPL-3.0-or-later
- fedora 44: libtalloc-devel 2.4.4-1.fc44 Β· LGPL-3.0-or-later
- fedora 44: libtalloc-devel 2.4.4-1.fc44 Β· LGPL-3.0-or-later
- opensuse-leap 16.0: talloc-man 2.4.3-160000.2.2 Β· LGPL-3.0-or-later
- opensuse-leap 16.0: talloc-man 2.4.3-160000.2.2 Β· LGPL-3.0-or-later
- opensuse-leap 16.0: talloc-man 2.4.3-160000.2.2 Β· LGPL-3.0-or-later
- opensuse-leap 16.0: talloc-man 2.4.3-160000.2.2 Β· LGPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms