std.runtime

Function Description

The runtime package is used to interact with the runtime environment of a program. It provides a series of functions and variables for controlling, managing, and monitoring the execution of the program.

Cangjie uses an automatic garbage collection system for memory management. The runtime package provides functions such as manually triggering garbage collection, setting garbage collection thresholds, and obtaining memory statistics for controlling and monitoring garbage collection.

API List

Function

NameDescription
dumpHeapData(Path)Generates heap memory snapshot information and writes the information to a file in the specified path.
GC(Bool) (deprecated)Executes GC.
gc(Bool)Executes GC.
getAllocatedHeapSizeObtains the occupied size of the Cangjie heap, measured in bytes.
getBlockingThreadCountObtains the number of blocked Cangjie threads.
getGCCountObtains the number of times that GC is triggered.
getGCFreedSizeObtains the memory successfully reclaimed after GC is triggered, measured in bytes.
getGCTimeObtains the total duration of the triggered GC, measured in μs.
getMaxHeapSizeObtains the maximum usable size of the Cangjie heap, measured in bytes.
getNativeThreadCountObtains the number of physical threads.
getProcessorCountObtains the number of processors.
getThreadCountObtains the number of current Cangjie threads.
getUsedHeapSizeObtains the size of the physical memory occupied by the Cangjie heap on the Linux platform, measured in bytes. Obtains the size of the physical memory occupied by the Cangjie process on the Windows and macOS platforms, measured in bytes.
SetGCThreshold(UInt64) (deprecated)Modifies the memory threshold for triggering GC. If the size of a Cangjie heap exceeds the threshold measured in KB, GC is triggered.
setGCThreshold(UInt64)Modifies the memory threshold for triggering GC. If the size of a Cangjie heap exceeds the threshold measured in KB, GC is triggered.
startCPUProfilingStarts CPU profiler tracing.
stopCPUProfiling(Path)Stops CPU profiler tracing and writes records to a file in the specified path.

Struct

NameDescription
MemoryInfo (deprecated)Provides APIs for obtaining heap memory statistics.
ProcessorInfo (deprecated)Provides APIs for obtaining processor information.
ThreadInfo (deprecated)Provides APIs for obtaining Cangjie thread statistics.