106
Managing Library Behavior
The pmemobj_set_funcs() function allows an application to override memory allocation
calls used internally by libpmemobj. Passing in NULL for any of the handlers will cause
the libpmemobj default function to be used. The library does not make heavy use of the
system malloc() functions, but it does allocate approximately 4–8 kilobytes for each
memory pool in use.
By default, libpmemobj supports up to 1024 parallel transactions/allocations. For
debugging purposes, it is possible to decrease this value by setting the PMEMOBJ_NLANES
shell environment variable to the desired limit. For example, at the shell prompt, run
"export PMEMOBJ_NLANES=512" then run the application:
$ export PMEMOBJ_NLANES=512
$ ./my_app
To return to the default behavior, unset PMEMOBJ_NLANES using
$ unset PMEMOBJ_NLANES
Debugging and Error Handling
If an error is detected during the call to a libpmemobj function, the application
may retrieve an error message describing the reason for the failure from pmemobj_
errormsg(). This function returns a pointer to a static buffer containing the last error
message logged for the current thread. If errno was set, the error message may include
a description of the corresponding error code as returned by strerror(3). The error
message buffer is thread local; errors encountered in one thread do not affect its value
in other threads. The buffer is never cleared by any library function; its content is
significant only when the return value of the immediately preceding call to a libpmemobj
function indicated an error, or if errno was set. The application must not modify or free
the error message string, but it may be modified by subsequent calls to other library
functions.
Two versions of libpmemobj are typically available on a development system. The
non-debug version is optimized for performance and used when a program is linked
using the -lpmemobj option. This library skips checks that impact performance, never
logs any trace information, and does not perform any runtime assertions.
Chapter 7 libpmemobj: a Native traNsaCtioNal objeCt store
Managing Library Behavior
The pmemobj_set_funcs() function allows an application to override memory allocation
calls used internally by libpmemobj. Passing in NULL for any of the handlers will cause
the libpmemobj default function to be used. The library does not make heavy use of the
system malloc() functions, but it does allocate approximately 4–8 kilobytes for each
memory pool in use.
By default, libpmemobj supports up to 1024 parallel transactions/allocations. For
debugging purposes, it is possible to decrease this value by setting the PMEMOBJ_NLANES
shell environment variable to the desired limit. For example, at the shell prompt, run
"export PMEMOBJ_NLANES=512" then run the application:
$ export PMEMOBJ_NLANES=512
$ ./my_app
To return to the default behavior, unset PMEMOBJ_NLANES using
$ unset PMEMOBJ_NLANES
Debugging and Error Handling
If an error is detected during the call to a libpmemobj function, the application
may retrieve an error message describing the reason for the failure from pmemobj_
errormsg(). This function returns a pointer to a static buffer containing the last error
message logged for the current thread. If errno was set, the error message may include
a description of the corresponding error code as returned by strerror(3). The error
message buffer is thread local; errors encountered in one thread do not affect its value
in other threads. The buffer is never cleared by any library function; its content is
significant only when the return value of the immediately preceding call to a libpmemobj
function indicated an error, or if errno was set. The application must not modify or free
the error message string, but it may be modified by subsequent calls to other library
functions.
Two versions of libpmemobj are typically available on a development system. The
non-debug version is optimized for performance and used when a program is linked
using the -lpmemobj option. This library skips checks that impact performance, never
logs any trace information, and does not perform any runtime assertions.
Chapter 7 libpmemobj: a Native traNsaCtioNal objeCt store
