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
| Name | Description |
|---|---|
| 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. |
| getAllocatedHeapSize | Obtains the occupied size of the Cangjie heap, measured in bytes. |
| getBlockingThreadCount | Obtains the number of blocked Cangjie threads. |
| getGCCount | Obtains the number of times that GC is triggered. |
| getGCFreedSize | Obtains the memory successfully reclaimed after GC is triggered, measured in bytes. |
| getGCTime | Obtains the total duration of the triggered GC, measured in μs. |
| getMaxHeapSize | Obtains the maximum usable size of the Cangjie heap, measured in bytes. |
| getNativeThreadCount | Obtains the number of physical threads. |
| getProcessorCount | Obtains the number of processors. |
| getThreadCount | Obtains the number of current Cangjie threads. |
| getUsedHeapSize | Obtains 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. |
| startCPUProfiling | Starts CPU profiler tracing. |
| stopCPUProfiling(Path) | Stops CPU profiler tracing and writes records to a file in the specified path. |
Struct
| Name | Description |
|---|---|
| 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. |