Expand description
This module defines C FFI definitions of dlmalloc library. Use this library only if you understand the safety.
Structs§
- Mall
Info - This structure is returned by
dlmallinfoandmspace_mallinforoutines.
It reports the current status of the heap.
Constants§
- M_
GRANULARITY - Used by
dlmalloptroutine.
Defines the granularity of the page size. (e.g.: 4K for x86) - M_
MMAP_ THRESHOLD - Used by
dlmalloptroutine.
Defines the minimum size ofmmapcall. - M_
TRIM_ THRESHOLD - Used by
dlmalloptroutine.
Defines when dlmalloc will trim blank pages.
Functions§
- create_
mspace ⚠ create_mspacecreates 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_mspacedestroys 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_callocbehaves 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_callocbehaves as independent_calloc, but operates within the given space.- mspace_
independent_ ⚠comlloc mspace_independent_comallocbehaves as independent_comalloc, but operates within the given space.- mspace_
mallinfo ⚠ mspace_mallinfobehaves as mallinfo, but reports properties of the given space.- mspace_
malloc ⚠ mspace_mallocbehaves 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_memalignbehaves as memalign, but operates within the given space.- mspace_
realloc ⚠ mspace_reallocbehaves as realloc, but operates within the given space.- mspace_
realloc_ ⚠in_ place mspace_realloc_in_placebehaves as realloc_in_place, but operates within the given space.- mspace_
track_ ⚠large_ chunks mspace_track_large_chunkscontrols 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_trimbehaves as malloc_trim, but operates within the given space.