4.43.2 Heap memory (malloc)
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • Memory Management
          • Heap memory (malloc)
            • trim_heap/0
            • TCMalloc control predicates
              • malloc_property/1
              • set_malloc/1
              • thread_idle/2
    • Packages

4.43.2.1 TCMalloc control predicates

If SWI-Prolog core detects that tcmalloc is the current allocator and provides the following additional predicates.

[nondet]malloc_property(?Property)
True when Property is a property of the current allocator. The properties are defined by the allocator. The properties of tcmalloc are defined in gperftools/malloc_extension.h:166Documentation copied from the header.
’generic.current_allocated_bytes'(-Int)
Number of bytes currently allocated by application.
’generic.heap_size'(-Int)
Number of bytes in the heap (= current_allocated_bytes + fragmentation + freed memory regions).
’tcmalloc.max_total_thread_cache_bytes'(-Int)
Upper limit on total number of bytes stored across all thread caches.
’tcmalloc.current_total_thread_cache_bytes'(-Int)
Number of bytes used across all thread caches.
’tcmalloc.central_cache_free_bytes'(-Int)
Number of free bytes in the central cache that have been assigned to size classes. They always count towards virtual memory usage, and unless the underlying memory is swapped out by the OS, they also count towards physical memory usage.
’tcmalloc.transfer_cache_free_bytes'(-Int)
Number of free bytes that are waiting to be transferred between the central cache and a thread cache. They always count towards virtual memory usage, and unless the underlying memory is swapped out by the OS, they also count towards physical
’tcmalloc.thread_cache_free_bytes'(-Int)
Number of free bytes in thread caches. They always count towards virtual memory usage, and unless the underlying memory is swapped out by the OS, they also count towards physical memory usage.
’tcmalloc.pageheap_free_bytes'(-Int)
Number of bytes in free, mapped pages in page heap. These bytes can be used to fulfill allocation requests. They always count towards virtual memory usage, and unless the underlying memory is swapped out by the OS, they also count towards physical memory usage. This property is not writable.
’tcmalloc.pageheap_unmapped_bytes'(-Int)
Number of bytes in free, unmapped pages in page heap. These are bytes that have been released back to the OS, possibly by one of the MallocExtension "Release" calls. They can be used to fulfill allocation requests, but typically incur a page fault. They always count towards virtual memory usage, and depending on the OS, typically do not count towards physical memory usage.
[det]set_malloc(+Property)
Set properties described in malloc_property/1. Currently the only writable property is tcmalloc.max_total_thread_cache_bytes. Setting an unknown property raises a domain_error and setting a read-only property raises a permission_error exception.
[semidet]thread_idle(:Goal, +Duration)
Indicates to the system that the calling thread will idle for some time while calling Goal as once/1. This call releases resources to the OS to minimise the footprint of the calling thread while it waits. Despite the name this predicate is always provided, also if the system is not configured with tcmalloc or is single threaded. Duration is one of
short
Calls trim_stacks/0 and, if tcmalloc is used, calls MallocExtension_MarkThreadTemporarilyIdle() which empties the thread's malloc cache but preserves the cache itself.
long
Calls garbage_collect/0 and trim_stacks/0 and, if tcmalloc is used, calls MallocExtension_MarkThreadIdle() which releases all thread-specific allocation data structures.