Module malloc

Module malloc 

Source
Expand description

Various malloc implementations (conditionally compiled by features) This module exposes a set of malloc API. They are currently implemented with the library malloc. This may change in the future, and will be replaced with a native MMTk implementation. We have two versions for each function:

  • a normal version: it has the signature that is compatible with the standard malloc library.
  • a counted version: the allocated/freed bytes are calculated into MMTk’s heap. So extra arguments are needed to maintain allocated bytes properly. The API is inspired by Julia’s counted malloc. The counted version is only available with the feature malloc_counted_size.

Modules§

library 🔒
Malloc provided by libraries
malloc_ms_util 🔒
Using malloc as mark sweep free-list allocator.

Functions§

calloc
Manually allocate memory and initialize the bytes in the allocated memory to zero. Similar to libc’s calloc.
counted_calloc
Manually allocate memory and initialize the bytes in the allocated memory to zero. Similar to libc’s calloc. This also counts the allocated memory into the heap size of the given MMTk instance.
counted_malloc
Manually allocate memory. Similar to libc’s malloc. This also counts the allocated memory into the heap size of the given MMTk instance.
free
Manually free the memory that is returned from other manual allocation functions in this module.
free_with_size
Manually free the memory that is returned from other manual allocation functions in this module. This also reduces the allocated memory size.
malloc
Manually allocate memory. Similar to libc’s malloc.
realloc
Reallocate the given area of memory. Similar to libc’s realloc.
realloc_with_old_size
Reallocate the given area of memory. Similar to libc’s realloc. This also adjusts the allocated memory size based on the original allocation and the new allocation, and counts that into the heap size for the given MMTk instance.