Documentation
¶
Index ¶
- func Calloc(num, size uintptr) uintptr
- func CallocCap(num, size uintptr) (uintptr, uintptr)
- func Free(ptr uintptr)
- func Init()
- func InitThread()
- func Malloc(size uintptr) uintptr
- func MallocCap(size uintptr) (uintptr, uintptr)
- func MallocZeroed(size uintptr) uintptr
- func MallocZeroedCap(size uintptr) (uintptr, uintptr)
- func ReadGlobalStats(stats *GlobalStats)
- func ReadThreadStats(stats *ThreadStats)
- func Realloc(ptr, size uintptr) uintptr
- func ReallocCap(ptr, size uintptr) (uintptr, uintptr)
- func StdFree(ptr uintptr)
- func StdMalloc(size uintptr) uintptr
- func UsableSize(ptr uintptr) uintptr
- type Config
- type GlobalStats
- type Heap
- func (h *Heap) Alloc(size uintptr) uintptr
- func (h *Heap) AllocCap(size uintptr) (uintptr, uintptr)
- func (h *Heap) Calloc(num, size uintptr) uintptr
- func (h *Heap) CallocCap(num, size uintptr) (uintptr, uintptr)
- func (h *Heap) Free(ptr uintptr)
- func (h *Heap) FreeAll()
- func (h *Heap) Realloc(ptr, size uintptr, flags int32) uintptr
- func (h *Heap) ReallocCap(ptr, size uintptr, flags int32) (uintptr, uintptr)
- func (h *Heap) Release()
- type SizeUse
- type SpanStats
- type ThreadStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitThread ¶
func InitThread()
func MallocZeroed ¶
Malloc allocate a memory block of at least the given size
func MallocZeroedCap ¶
MallocZeroedCap allocate a memory block of at least the given size
func ReadGlobalStats ¶
func ReadGlobalStats(stats *GlobalStats)
ReadGlobalStats get global statistics
func ReadThreadStats ¶
func ReadThreadStats(stats *ThreadStats)
ReadThreadStats get thread statistics
func ReallocCap ¶
Realloc the given block to at least the given size
func UsableSize ¶
UsableSize Query the usable size of the given memory block (from given pointer to the end of block)
Types ¶
type Config ¶
type Config struct {
//! Map memory pages for the given number of bytes. The returned address MUST be
// aligned to the rpmalloc span size, which will always be a power of two.
// Optionally the function can store an alignment offset in the offset variable
// in case it performs alignment and the returned pointer is offset from the
// actual start of the memory region due to this alignment. The alignment offset
// will be passed to the memory unmap function. The alignment offset MUST NOT be
// larger than 65535 (storable in an uint16_t), if it is you must use natural
// alignment to shift it into 16 bits. If you set a memory_map function, you
// must also set a memory_unmap function or else the default implementation will
// be used for both.
MemoryMap uintptr
//! Unmap the memory pages starting at address and spanning the given number of bytes.
// If release is set to non-zero, the unmap is for an entire span range as returned by
// a previous libfuzzerCall to memory_map and that the entire range should be released. The
// release argument holds the size of the entire span range. If release is set to 0,
// the unmap is a partial decommit of a subset of the mapped memory range.
// If you set a memory_unmap function, you must also set a memory_map function or
// else the default implementation will be used for both.
MemoryUnmap uintptr
//! Called when an assert fails, if asserts are enabled. Will use the standard assert()
// if this is not set.
ErrorCallback uintptr
//! Called when a libfuzzerCall to map memory pages fails (out of memory). If this callback is
// not set or returns zero the library will return a null pointer in the allocation
// libfuzzerCall. If this callback returns non-zero the map libfuzzerCall will be retried. The argument
// passed is the number of bytes that was requested in the map libfuzzerCall. Only used if
// the default system memory map function is used (memory_map callback is not set).
MapFailCallback uintptr
//! Size of memory pages. The page size MUST be a power of two. All memory mapping
// requests to memory_map will be made with size set to a multiple of the page size.
// Used if RPMALLOC_CONFIGURABLE is defined to 1, otherwise system page size is used.
PageSize uintptr
//! Size of a span of memory blocks. MUST be a power of two, and in [4096,262144]
// range (unless 0 - set to 0 to use the default span size). Used if RPMALLOC_CONFIGURABLE
// is defined to 1.
SpanSize uintptr
//! Number of spans to map at each request to map new virtual memory blocks. This can
// be used to minimize the system libfuzzerCall overhead at the cost of virtual memory address
// space. The extra mapped pages will not be written until actually used, so physical
// committed memory should not be affected in the default implementation. Will be
// aligned to a multiple of spans that match memory page size in case of huge pages.
SpanMapCount uintptr
//! Enable use of large/huge pages. If this flag is set to non-zero and page size is
// zero, the allocator will try to enable huge pages and auto detect the configuration.
// If this is set to non-zero and page_size is also non-zero, the allocator will
// assume huge pages have been configured and enabled prior to initializing the
// allocator.
// For Windows, see https://docs.microsoft.com/en-us/windows/desktop/memory/large-page-support
// For Linux, see https://www.kernel.org/doc/Documentation/vm/hugetlbpage.txt
EnableHugePages int32
Unused int32
}
type GlobalStats ¶
type GlobalStats struct {
//! Current amount of virtual memory mapped, all of which might not have been committed (only if ENABLE_STATISTICS=1)
Mapped uintptr
//! Peak amount of virtual memory mapped, all of which might not have been committed (only if ENABLE_STATISTICS=1)
MappedPeak uintptr
//! Current amount of memory in global caches for small and medium sizes (<32KiB)
Cached uintptr
//! Current amount of memory allocated in huge allocations, i.e larger than LARGE_SIZE_LIMIT which is 2MiB by default (only if ENABLE_STATISTICS=1)
HugeAlloc uintptr
//! Peak amount of memory allocated in huge allocations, i.e larger than LARGE_SIZE_LIMIT which is 2MiB by default (only if ENABLE_STATISTICS=1)
HugeAllocPeak uintptr
//! Total amount of memory mapped since initialization (only if ENABLE_STATISTICS=1)
MappedTotal uintptr
//! Total amount of memory unmapped since initialization (only if ENABLE_STATISTICS=1)
UnmappedTotal uintptr
}
type Heap ¶
type Heap C.rpmalloc_heap_t
func AcquireHeap ¶
func AcquireHeap() *Heap
func (*Heap) AllocCap ¶
AllocCap Allocate a memory block of at least the given size using the given heap.
func (*Heap) Calloc ¶
Calloc Allocate a memory block of at least the given size using the given heap and zero initialize it.
func (*Heap) CallocCap ¶
Calloc Allocate a memory block of at least the given size using the given heap and zero initialize it.
func (*Heap) Free ¶
Free the given memory block from the given heap. The memory block MUST be allocated by the same heap given to this function.
func (*Heap) Realloc ¶
Realloc Reallocate the given block to at least the given size. The memory block MUST be allocated by the same heap given to this function.
func (*Heap) ReallocCap ¶
ReallocCap Reallocate the given block to at least the given size. The memory block MUST be allocated by the same heap given to this function.
type SizeUse ¶
type SizeUse struct {
//! Current number of allocations
AllocCurrent uintptr
//! Peak number of allocations
AllocPeak uintptr
//! Total number of allocations
AllocTotal uintptr
//! Total number of frees
FreeTotal uintptr
//! Number of spans transitioned to cache
SpansToCache uintptr
//! Number of spans transitioned from cache
SpansFromCache uintptr
//! Number of spans transitioned from reserved state
SpansFromReserved uintptr
//! Number of raw memory map calls (not hitting the reserve spans but resulting in actual OS mmap calls)
MapCalls uintptr
}
type SpanStats ¶
type SpanStats struct {
//! Currently used number of spans
Current uintptr
//! High water mark of spans used
Peak uintptr
//! Number of spans transitioned to global cache
ToGlobal uintptr
//! Number of spans transitioned from global cache
FromGlobal uintptr
//! Number of spans transitioned to thread cache
ToCache uintptr
//! Number of spans transitioned from thread cache
FromCache uintptr
//! Number of spans transitioned to reserved state
ToReserved uintptr
//! Number of spans transitioned from reserved state
FromReserved uintptr
//! Number of raw memory map calls (not hitting the reserve spans but resulting in actual OS mmap calls)
MapCalls uintptr
}
type ThreadStats ¶
type ThreadStats struct {
//! Current number of bytes available in thread size class caches for small and medium sizes (<32KiB)
SizeCache uintptr
//! Current number of bytes available in thread span caches for small and medium sizes (<32KiB)
SpanCache uintptr
//! Total number of bytes transitioned from thread cache to global cache (only if ENABLE_STATISTICS=1)
ThreadToGlobal uintptr
//! Total number of bytes transitioned from global cache to thread cache (only if ENABLE_STATISTICS=1)
GlobalToThread uintptr
//! Per span count statistics (only if ENABLE_STATISTICS=1)
SpanUse [64]SpanStats
//! Per size class statistics (only if ENABLE_STATISTICS=1)
SizeUse [128]SizeUse
}
Directories
¶
| Path | Synopsis |
|---|---|
|
See https://github.com/golang/go/issues/26366.
|
See https://github.com/golang/go/issues/26366. |
|
darwin_amd64
See https://github.com/golang/go/issues/26366.
|
See https://github.com/golang/go/issues/26366. |
|
darwin_arm64
See https://github.com/golang/go/issues/26366.
|
See https://github.com/golang/go/issues/26366. |
|
linux_amd64
See https://github.com/golang/go/issues/26366.
|
See https://github.com/golang/go/issues/26366. |