std.runtime

Function Overview

The runtime package facilitates interaction with the program's runtime environment, providing a series of functions and variables for controlling, managing, and monitoring program execution.

The Cangjie language employs an automatic garbage collection mechanism for memory management. The runtime package offers functionalities such as manual garbage collection triggering, garbage collection threshold configuration, and memory statistics retrieval for garbage collection tuning and monitoring.

API List

Functions

Function Name Description
dumpHeapData(Path) Generates heap memory snapshot information and writes it to a file at the specified path.
GC(Bool) (deprecated) Executes garbage collection.
gc(Bool) Executes garbage collection.
getAllocatedHeapSize Retrieves the allocated heap size in bytes for the Cangjie heap.
getBlockingThreadCount Gets the count of blocked Cangjie threads.
getGCCount Retrieves the number of garbage collection triggers.
getGCFreedSize Gets the amount of memory successfully reclaimed after garbage collection, in bytes.
getGCTime Retrieves the total garbage collection duration in microseconds.
getMaxHeapSize Gets the maximum available size of the Cangjie heap in bytes.
getNativeThreadCount Retrieves the count of physical threads.
getProcessorCount Gets the number of processors.
getThreadCount Retrieves the current count of Cangjie threads.
getUsedHeapSize On Linux platforms: gets the actual physical memory usage of the Cangjie heap in bytes. On Windows and macOS platforms: gets the actual physical memory usage of the Cangjie process in bytes.
SetGCThreshold(UInt64) (deprecated) Modifies the user-defined memory threshold for garbage collection triggering (in KB). When the Cangjie heap size exceeds this value, garbage collection is triggered.
setGCThreshold(UInt64) Modifies the user-defined memory threshold for garbage collection triggering (in KB). When the Cangjie heap size exceeds this value, garbage collection is triggered.
startCPUProfiling Initiates CPU profiler tracing.
stopCPUProfiling(Path) Stops CPU profiler tracing and writes the records to a file at the specified path.

Structures

Structure Name Description
MemoryInfo (deprecated) Provides interfaces for retrieving heap memory statistics.
ProcessorInfo (deprecated) Provides interfaces for retrieving processor information.
ThreadInfo (deprecated) Provides interfaces for retrieving Cangjie thread statistics.