Module raw

Module raw 

Source
Expand description

This module defines C FFI definitions of dlmalloc library. Use this library only if you understand the safety.

Structs§

MallInfo
This structure is returned by dlmallinfo and mspace_mallinfo routines.
It reports the current status of the heap.

Constants§

M_GRANULARITY
Used by dlmallopt routine.
Defines the granularity of the page size. (e.g.: 4K for x86)
M_MMAP_THRESHOLD
Used by dlmallopt routine.
Defines the minimum size of mmap call.
M_TRIM_THRESHOLD
Used by dlmallopt routine.
Defines when dlmalloc will trim blank pages.

Functions§

create_mspace
create_mspace creates and returns a new independent space with the given initial capacity, or, if 0, the default granularity size. It returns null if there is no system memory available to create the space. If argument locked is non-zero, the space uses a separate lock to control access. The capacity of the space will grow dynamically as needed to service mspace_malloc requests. You can control the sizes of incremental increases of this space by compiling with a different DEFAULT_GRANULARITY or dynamically setting with mallopt(M_GRANULARITY, value).
create_mspace_with_base
`create_mspace_with_base`` uses the memory supplied as the initial base of a new mspace. Part (less than 128*sizeof(size_t) bytes) of this space is used for bookkeeping, so the capacity must be at least this large. (Otherwise 0 is returned.) When this initial space is exhausted, additional memory will be obtained from the system. Destroying this space will deallocate all additionally allocated space (if possible) but not the initial base.
destroy_mspace
destroy_mspace destroys the given space, and attempts to return all
dlbulk_free
bulk_free(void* array[], size_t n_elements)
dlcalloc
calloc(size_t n_elements, size_t element_size);
dlfree
dlfree(void* p)
dlindependent_calloc
independent_calloc(size_t n_elements, size_t element_size, void* chunks[]);
dlindependent_comalloc
independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]);
dlmallinfo
mallinfo()
dlmalloc
malloc(size_t n)
dlmalloc_footprint
malloc_footprint();
dlmalloc_footprint_limit
malloc_footprint_limit();
dlmalloc_inspect_all
malloc_inspect_all(void(*handler)(void *start,void *end,size_t used_bytes,void* callback_arg),void* arg);
dlmalloc_max_footprint
malloc_max_footprint();
dlmalloc_set_footprint_limit
malloc_set_footprint_limit();
dlmalloc_trim
malloc_trim(size_t pad);
dlmalloc_usable_size
malloc_usable_size(void* p);
dlmallopt
mallopt(int parameter_number, int parameter_value)
dlmemalign
memalign(size_t alignment, size_t n);
dlposix_memalign
int posix_memalign(void** pp, size_t alignment, size_t n);
dlpvalloc
pvalloc(size_t n); Equivalent to valloc(minimum-page-that-holds(n)), that is, round up n to nearest pagesize.
dlrealloc
realloc(void* p, size_t n)
dlrealloc_in_place
realloc_in_place(void* p, size_t n)
dlvalloc
valloc(size_t n);
mspace_calloc
mspace_calloc behaves as calloc, but operates within the given space.
mspace_footprint
mspace_footprint() returns the number of bytes obtained from the system for this space.
mspace_free
mspace_free behaves as free, but operates within the given space.
mspace_independent_calloc
mspace_independent_calloc behaves as independent_calloc, but operates within the given space.
mspace_independent_comlloc
mspace_independent_comalloc behaves as independent_comalloc, but operates within the given space.
mspace_mallinfo
mspace_mallinfo behaves as mallinfo, but reports properties of the given space.
mspace_malloc
mspace_malloc behaves as malloc, but operates within the given space.
mspace_max_footprint
mspace_max_footprint() returns the peak number of bytes obtained from the system for this space.
mspace_memalign
mspace_memalign behaves as memalign, but operates within the given space.
mspace_realloc
mspace_realloc behaves as realloc, but operates within the given space.
mspace_realloc_in_place
mspace_realloc_in_place behaves as realloc_in_place, but operates within the given space.
mspace_track_large_chunks
mspace_track_large_chunks controls whether requests for large chunks are allocated in their own untracked mmapped regions, separate from others in this mspace. By default large chunks are not tracked, which reduces fragmentation. However, such chunks are not necessarily released to the system upon destroy_mspace. Enabling tracking by setting to true may increase fragmentation, but avoids leakage when relying on destroy_mspace to release all memory allocated using this space. The function returns the previous setting.
mspace_trim
mspace_trim behaves as malloc_trim, but operates within the given space.

Type Aliases§

DLInspectHandler