April 2012
Intermediate to advanced
352 pages
8h
English
The malloc, free, realloc, and reallocf functions include a type argument, which expects a pointer to a malloc_type structure; this structure describes the purpose of the allocated memory. The type argument has no impact on performance; it is used for memory profiling and for basic sanity checks.
You can profile kernel dynamic memory usage, sorted by type, with the vmstat -m command.
The MALLOC_DEFINE macro defines a new malloc_type structure. Here is its function prototype:
#include <sys/param.h> #include <sys/malloc.h> #include <sys/kernel.h> MALLOC_DEFINE(type, shortdesc, longdesc);
The type argument is the new malloc_type structure’s name. In general, type should begin with M_ and be in uppercase letters; ...
Read now
Unlock full access