Skip to main content

Module sys

Module sys 

Source
Expand description

Raw bindings to the in-tree mimalloc static amalgamation.

Structs§

MiPurgeHolesStats
Mirrors mi_purge_holes_stats_t (issue #272, Bun parity P7b): what page hole purging actually reclaimed, process wide. Field order and types must match mimalloc.h exactly.
MiRsLayoutEntry
One entry of the ABI layout table published by mi_rs_layout_table.
mi_dhat_stats_t
Mirrors mi_dhat_stats_t (include/mimalloc/dhat.h) field-for-field.
mi_memory_callbacks_t
Mirrors mi_memory_callbacks_t (include/mimalloc/memory-events.h): one handler and one caller-owned arg per mi_memory_change_kind_t, indexed by the kind.
mi_memory_change_t
Mirrors mi_memory_change_t (include/mimalloc/memory-events.h) field-for-field.
mi_memory_snapshot_t
Mirrors mi_memory_snapshot_t (include/mimalloc/memory-events.h) field-for-field.
mi_prof_config_t
Mirrors mi_prof_config_t (include/mimalloc/profile.h) field-for-field.
mi_prof_module_info_t
Mirrors mi_prof_module_info_t (include/mimalloc/profile.h) field-for-field.
mi_prof_sample_info_t
Mirrors mi_prof_sample_info_t (include/mimalloc/profile.h) field-for-field.
mi_prof_stats_t
Mirrors mi_prof_stats_t (include/mimalloc/profile.h) field-for-field.
mi_stat_count_t
Mirrors mi_stat_count_t: a quantity tracked over time.
mi_stat_counter_t
Mirrors mi_stat_counter_t: a monotonically increasing counter.
mi_stats_t
Mirrors mi_stats_t (include/mimalloc-stats.h) field-for-field, including the reserved-for-future-use arrays and the three size-segregated bin arrays.
mi_subproc_id_t
Mirrors mi_subproc_id_t (include/mimalloc.h): an abstract, pointer-sized handle.

Enums§

mi_heap_t
Opaque handle for mi_heap_t (issue #269, Bun parity P4): only ever seen behind a pointer here (mi_heap_get_seq), so this type is never constructed on the Rust side.
mi_prof_snapshot_t
Opaque handle for mi_prof_snapshot_t; the profiler never hands out a value, only a pointer, so this type is never constructed on the Rust side.

Constants§

MI_BIN_HUGE
Mirrors MI_BIN_HUGE in include/mimalloc-stats.h; the bin arrays below hold MI_BIN_HUGE + 1 entries.
MI_CBIN_COUNT
Mirrors MI_CBIN_COUNT (mi_chunkbin_t) in include/mimalloc-stats.h.
MI_DHAT_STATS_VERSION
Mirrors MI_DHAT_STATS_VERSION in include/mimalloc/dhat.h.
MI_MEMORY_ALLOCATE
Mirrors MI_MEMORY_ALLOCATE.
MI_MEMORY_CHANGE_COUNT
Mirrors MI_MEMORY_CHANGE_COUNT: the number of callback slots, not a kind.
MI_MEMORY_FREE
Mirrors MI_MEMORY_FREE.
MI_MEMORY_RESIZE
Mirrors MI_MEMORY_RESIZE.
MI_MEMORY_SNAPSHOT_VERSION
Mirrors MI_MEMORY_SNAPSHOT_VERSION in include/mimalloc/memory-events.h.
MI_OPTIONS_IN_ORDER
Every enumerator of mi_option_t up to and including _mi_option_last, in C declaration order, as (name, value) pairs. Used by tests/t19_layout.rs to check this mirror against the C enum, and by ci/check_rust_surface.py to check it against include/mimalloc.h.
MI_PROF_CONFIG_FALLBACK
Mirrors mi_prof_config_mode_t’s MI_PROF_CONFIG_FALLBACK / MI_PROF_CONFIG_OVERRIDE (include/mimalloc/profile.h).
MI_PROF_CONFIG_OVERRIDE
MI_PROF_CONFIG_VERSION
Mirrors MI_PROF_CONFIG_VERSION in include/mimalloc/profile.h.
MI_PROF_FORMAT_PROTO
MI_PROF_FORMAT_TEXT
Mirrors MI_PROF_FORMAT_TEXT / MI_PROF_FORMAT_PROTO (include/mimalloc/profile.h).
MI_PROF_STAT_VERSION
Mirrors MI_PROF_STAT_VERSION in include/mimalloc/profile.h.
MI_STAT_VERSION
Mirrors MI_STAT_VERSION in include/mimalloc-stats.h.
_mi_option_last
Sentinel: one past the last real option.
mi_option_allow_large_os_pages
Allow large (2 MiB) OS pages.
mi_option_allow_thp
Allow transparent huge pages.
mi_option_arena_eager_commit
Eagerly commit arena memory.
mi_option_arena_is_numa_local
Treat arenas as NUMA local.
mi_option_arena_max_object_size
Largest object served from an arena.
mi_option_arena_purge_mult
Multiplier on the arena purge delay.
mi_option_arena_reserve
Bytes to reserve per new arena.
mi_option_deprecated_abandoned_page_purge
Deprecated; kept for numbering.
mi_option_deprecated_eager_commit
Deprecated; kept for numbering.
mi_option_deprecated_eager_commit_delay
Deprecated; kept for numbering.
mi_option_deprecated_max_segment_reclaim
Deprecated; kept for numbering.
mi_option_deprecated_page_reset
Deprecated; kept for numbering.
mi_option_deprecated_purge_extend_delay
Deprecated; kept for numbering.
mi_option_deprecated_segment_cache
Deprecated; kept for numbering.
mi_option_deprecated_segment_reset
Deprecated; kept for numbering.
mi_option_deprecated_visit_abandoned
Deprecated; kept for numbering.
mi_option_destroy_on_exit
Release all memory on process exit.
mi_option_disallow_arena_alloc
Refuse to allocate from arenas.
mi_option_disallow_os_alloc
Refuse to allocate from the OS.
mi_option_eager_region_commit
Deprecated upstream alias for mi_option_arena_eager_commit.
mi_option_generic_collect
Collect generically every N-th generic allocation.
mi_option_guarded_max
Maximum size for guard-page allocation.
mi_option_guarded_min
Minimum size for guard-page allocation.
mi_option_guarded_precise
Place guard pages precisely after the block.
mi_option_guarded_sample_rate
Sample every N-th allocation for guard pages.
mi_option_guarded_sample_seed
Seed for guard-page sampling.
mi_option_large_os_pages
Deprecated upstream alias for mi_option_allow_large_os_pages.
mi_option_limit_os_alloc
Deprecated upstream alias for mi_option_disallow_os_alloc.
mi_option_max_errors
Maximum error messages printed.
mi_option_max_vabits
Maximum virtual address bits to assume.
mi_option_max_warnings
Maximum warning messages printed.
mi_option_memory_events
Fork addition. Enable allocation-change accounting/callbacks (MIMALLOC_MEMORY_EVENTS).
mi_option_minimal_purge_size
Smallest range worth purging.
mi_option_os_tag
Tag passed to the OS allocator.
mi_option_page_commit_on_demand
Commit page memory on demand.
mi_option_page_cross_thread_max_reclaim
Maximum cross-thread pages reclaimed at once.
mi_option_page_full_retain
Number of full pages to retain per bin.
mi_option_page_max_candidates
Candidate pages searched per allocation.
mi_option_page_max_reclaim
Maximum pages reclaimed at once.
mi_option_page_reclaim_on_free
Reclaim abandoned pages on free.
mi_option_pagemap_commit
Commit the page map eagerly.
mi_option_prof
Fork addition. Enable the allocation sampling profiler at process start (MIMALLOC_PROF).
mi_option_prof_accum
Fork addition. Keep cumulative profiler counters until mi_prof_reset.
mi_option_prof_bt_max
Fork addition. Maximum captured stack depth for the profiler.
mi_option_prof_max_bytes
Fork addition. Budget in bytes for profiler-internal arena memory.
mi_option_prof_sample_rate
Fork addition. Average byte interval between profiler samples.
mi_option_prof_seed
Fork addition. Profiler sampling PRNG seed; 0 = nondeterministic.
mi_option_purge_decommits
Purge decommits rather than resets.
mi_option_purge_delay
Milliseconds to delay purging.
mi_option_purge_holes
Fork addition (Bun). Discard the memory of free blocks inside still-used pages on mi_on_thread_idle.
mi_option_purge_holes_eager_zero
Fork addition (Bun). Zero a range before discarding it, so a mis-scoped discard corrupts visibly.
mi_option_purge_holes_full_every
Fork addition (Bun). Every N-th sweep walks every page, ignoring the per-page skip check; 0 disables.
mi_option_purge_holes_min_interval
Fork addition (Bun). Minimum milliseconds between sweeps of one thread’s heaps.
mi_option_purge_zeroes
Fork addition, dead since #80. The slot is kept so nothing renumbers; setting it parses but has no effect. Unrelated to mi_option_purge_holes_eager_zero.
mi_option_reserve_huge_os_pages
Reserve N huge OS pages at startup.
mi_option_reserve_huge_os_pages_at
Reserve huge OS pages at a specific NUMA node.
mi_option_reserve_os_memory
Reserve N KiB of OS memory at startup.
mi_option_reset_decommits
Deprecated upstream alias for mi_option_purge_decommits.
mi_option_reset_delay
Deprecated upstream alias for mi_option_purge_delay.
mi_option_retry_on_oom
Retry count on OS out-of-memory.
mi_option_scavenger
Fork addition (Bun). Run a background thread that purges scheduled arena memory.
mi_option_show_errors
Print error messages.
mi_option_show_stats
Print statistics on termination.
mi_option_use_numa_nodes
Number of NUMA nodes to use.
mi_option_verbose
Print verbose messages.

Functions§

mi_calloc
mi_dhat_dump
mi_dhat_is_enabled
mi_dhat_start
mi_dhat_stats_get
mi_dhat_stop
mi_expand
Grow in place only; returns NULL if the block cannot be extended without moving.
mi_free
mi_heap_dump_json
Live per-heap -> per-page -> (optional) per-block JSON snapshot (issue #269, Bun parity P4). Backs Bun’s shipped bun:jsc heapStats({dump:true|"blocks"}). Returns NULL on allocation failure; a non-NULL result is mi_malloc-family memory the caller must free with mi_free (see prof::heap_dump_json for the safe wrapper).
mi_heap_get_seq
Mirrors mi_heap_get_seq (include/mimalloc-stats.h): the monotonic sequence number assigned to heap at creation, or 0 for a NULL heap.
mi_heap_stats_get
Mirrors mi_heap_stats_get.
mi_heap_stats_get_json
Mirrors mi_heap_stats_get_json.
mi_heap_stats_merge_to_subproc
Mirrors mi_heap_stats_merge_to_subproc: fold a heap’s stats into its subprocess and clear the heap’s own.
mi_heap_stats_print_out
Mirrors mi_heap_stats_print_out.
mi_malloc
mi_malloc_aligned
mi_memory_set_callbacks
Mirrors mi_memory_set_callbacks. callbacks == NULL clears the table. The arg pointers are caller-owned and must stay valid until replaced or cleared.
mi_memory_snapshot
Mirrors mi_memory_snapshot; fill size/version in before calling.
mi_memory_tracking_is_enabled
Mirrors mi_memory_tracking_is_enabled.
mi_memory_tracking_set_enabled
Mirrors mi_memory_tracking_set_enabled; returns the previous state. An explicit call is always authoritative over the MIMALLOC_MEMORY_EVENTS environment read.
mi_memory_visit_live_allocations
Mirrors mi_memory_visit_live_allocations. Best effort, not a consistent global snapshot; the visitor must not allocate, free, or reenter mimalloc.
mi_on_thread_idle
Mirrors mi_on_thread_idle (issue #272, Bun parity P7a).
mi_on_thread_idle_end
Mirrors mi_on_thread_idle_end.
mi_on_thread_idle_start
Mirrors mi_on_thread_idle_start; false means nothing was handed off and mi_on_thread_idle_end must NOT be called.
mi_option_disable
Mirrors mi_option_disable.
mi_option_enable
Mirrors mi_option_enable.
mi_option_get
Mirrors mi_option_get.
mi_option_get_clamp
Mirrors mi_option_get_clamp.
mi_option_get_size
Mirrors mi_option_get_size.
mi_option_is_enabled
Mirrors mi_option_is_enabled.
mi_option_set
Mirrors mi_option_set.
mi_option_set_default
Mirrors mi_option_set_default.
mi_option_set_enabled
Mirrors mi_option_set_enabled.
mi_option_set_enabled_default
Mirrors mi_option_set_enabled_default.
mi_options_print_out
Mirrors mi_options_print_out: prints every option’s current value.
mi_prof_debug_stats
mi_prof_dump
mi_prof_dump_proto
profile.proto (google/pprof) writer: same sample/period/mapping semantics as mi_prof_dump/mi_prof_dump_writer but encoded as an uncompressed, binary pprof Profile message instead of the legacy “heap profile:” text.
mi_prof_dump_proto_writer
mi_prof_dump_writer
mi_prof_is_enabled
mi_prof_modules_visit
Structured module (mapping) enumeration, e.g. to build pprof Mapping entries yourself. No profiler lock is taken: module lists are OS-owned, not part of the sampled-allocation table. info (and info->path) are valid only for the duration of the callback.
mi_prof_reset
mi_prof_snapshot_free
mi_prof_snapshot_new
mi_prof_snapshot_visit
mi_prof_start
mi_prof_start_ex
mi_prof_start_seeded
mi_prof_stats_get
mi_prof_stop
mi_prof_visit
mi_purge_holes_report
Mirrors mi_purge_holes_report (issue #272, Bun parity P7b): prints, per size class, the free bytes hole purging could NOT discard. Read-only; purges nothing.
mi_purge_holes_stats_get
Mirrors mi_purge_holes_stats_get (issue #272, Bun parity P7b).
mi_realloc
mi_realloc_aligned
mi_recalloc
mi_recalloc_aligned
mi_rezalloc
mi_rezalloc_aligned
mi_rs_layout_table
Publishes what the C compiler laid out for every mirrored type, constant and option in this module. Defined by layout_probe.c (a rust/-side verification artifact, not part of the C library) and consumed by tests/t19_layout.rs.
mi_scavenger_stop
Mirrors mi_scavenger_stop (issue #272).
mi_stats_as_json
Mirrors mi_stats_as_json: render an already-captured mi_stats_t.
mi_stats_get
Mirrors mi_stats_get: aggregated stats for the current subprocess and its heaps.
mi_stats_get_bin_size
Mirrors mi_stats_get_bin_size: the block size served by size bin bin.
mi_stats_get_json
Mirrors mi_stats_get_json. With buf == NULL the result is mi_malloc-family memory the caller must release with mi_free.
mi_stats_print_out
Mirrors mi_stats_print_out.
mi_subproc_current
Mirrors mi_subproc_current: the subprocess this thread belongs to.
mi_subproc_heap_stats_print_out
Mirrors mi_subproc_heap_stats_print_out: the subprocess and each of its heaps, printed separately.
mi_subproc_main
Mirrors mi_subproc_main: the process-wide default subprocess.
mi_subproc_stats_get
Mirrors mi_subproc_stats_get.
mi_subproc_stats_get_exclusive
Mirrors mi_subproc_stats_get_exclusive: the subprocess’s own stats, without aggregating its heaps.
mi_subproc_stats_get_json
Mirrors mi_subproc_stats_get_json.
mi_subproc_stats_print_out
Mirrors mi_subproc_stats_print_out.
mi_unwrapped_free
Mirrors mi_unwrapped_free (include/mimalloc/memory-events.h).
mi_unwrapped_malloc
Mirrors mi_unwrapped_malloc (include/mimalloc/memory-events.h): backed directly by the raw OS layer, never by the hooked mi_malloc family. See that header’s “Stable public unwrapped instrumentation allocation path” comment for the full contract.
mi_unwrapped_realloc
Mirrors mi_unwrapped_realloc (include/mimalloc/memory-events.h).
mi_usable_size
mi_zalloc
mi_zalloc_aligned

Type Aliases§

MiProfWriteFun
mi_memory_allocation_visit_fun
Mirrors mi_memory_allocation_visit_fun (include/mimalloc/memory-events.h).
mi_memory_change_fun
Mirrors mi_memory_change_fun (include/mimalloc/memory-events.h).
mi_memory_change_kind_t
Mirrors mi_memory_change_kind_t. Declared as a plain c_int rather than a Rust enum on purpose: the value is produced by C, and materialising an out-of-range discriminant into a #[repr(i32)] enum would be undefined behaviour.
mi_option_t
Mirrors mi_option_t (include/mimalloc.h).
mi_output_fun
Mirrors mi_output_fun (include/mimalloc.h): mimalloc’s text output sink.
mi_prof_module_visit_fun
mi_prof_visit_fun