Functions
func dumpHeapData(Path)
public func dumpHeapData(path: Path): Unit
Description: Generates heap memory snapshot information and writes the information to a file in the specified path.
Parameters:
- path: Path: path of the generated heap memory snapshot file
Throws:
- MemoryInfoException: If the heap memory snapshot fails to be generated, this exception is thrown.
func GC(Bool) (deprecated)
public func GC(heavy!: Bool = false): Unit
Description: Executes GC.
NOTE
This function will be deprecated in future releases and gc will be used instead.
Parameters:
- heavy!: Bool: GC execution progress. If the value is true, the execution is slow and more memory is collected. The default value is false.
func gc(Bool)
public func gc(heavy!: Bool = false): Unit
Description: Executes gc.
Parameters:
- heavy!: Bool: gc execution progress. If the value is true, the execution is slow and more memory is collected. The default value is false.
func getAllocatedHeapSize()
public func getAllocatedHeapSize(): Int64
Description: Obtains the occupied size of the Cangjie heap, measured in bytes.
Returns:
- Int64: occupied size of the Cangjie heap, measured in bytes
func getBlockingThreadCount()
public func getBlockingThreadCount(): Int64
Description: Obtains the number of blocked Cangjie threads.
Returns:
- Int64: number of blocked Cangjie threads
func getGCCount()
public func getGCCount(): Int64
Description: Obtains the number of times that GC is triggered.
Returns:
- Int64: number of times that GC is triggered
func getGCFreedSize()
public func getGCFreedSize(): Int64
Description: Obtains the memory successfully reclaimed after GC is triggered, measured in bytes.
Returns:
- Int64: memory successfully reclaimed after GC is triggered, measured in bytes
func getGCTime()
public func getGCTime(): Int64
Description: Obtains the total duration of the triggered GC, measured in μs.
Returns:
- Int64: total duration of the triggered GC, measured in μs
func getMaxHeapSize()
public func getMaxHeapSize(): Int64
Description: Obtains the maximum usable size of the Cangjie heap, measured in bytes.
Returns:
- Int64: maximum usable size of the Cangjie heap, measured in bytes
func getNativeThreadCount()
public func getNativeThreadCount(): Int64
Description: Obtains the number of physical threads.
Returns:
- Int64: number of physical threads
func getProcessorCount()
public func getProcessorCount(): Int64
Description: Obtains the number of processors.
Returns:
- Int64: number of processors
func getThreadCount()
public func getThreadCount(): Int64
Description: Obtains the number of current Cangjie threads.
Returns:
- Int64: number of current Cangjie threads
func getUsedHeapSize()
public func getUsedHeapSize(): Int64
Description: 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.
Returns:
- Int64: size of the physical memory occupied by the Cangjie heap or process, measured in bytes
func SetGCThreshold(UInt64) (deprecated)
public func SetGCThreshold(value: UInt64): Unit
Description: Modifies the memory threshold for triggering GC. When the size of a Cangjie heap exceeds the threshold measured in KB, GC is triggered.
NOTE
This function will be deprecated in future releases and setGCThreshold(UInt64) will be used instead.
Parameters:
Examples: Sets the memory threshold for triggering GC to 2 MB.
import std.runtime.*
main() {
SetGCThreshold(2048)
}
func setGCThreshold(UInt64)
public func setGCThreshold(value: UInt64): Unit
Description: Modifies the memory threshold for triggering gc. When the size of a Cangjie heap exceeds the threshold measured in KB, gc is triggered.
Parameters:
Examples: Sets the memory threshold for triggering gc to 2 MB.
import std.runtime.*
main() {
setGCThreshold(2048)
}
func startCPUProfiling()
public func startCPUProfiling(): Unit
Description: Starts CPU profiler tracing.
Throws:
- The two functions ProfilingInfoException - startCPUProfiling and stopCPUProfiling(Path) must correspond to each other. After startCPUProfiling is called, if stopCPUProfiling(Path) is not called but startCPUProfiling is called again, this exception is thrown.
func stopCPUProfiling(Path)
public func stopCPUProfiling(path: Path): Unit
Description: Stops CPU profiler tracing and writes records to a file in the specified path.
Parameters:
- path: Path: path of the generated record file
Throws:
- The two functions ProfilingInfoException - startCPUProfiling and stopCPUProfiling(Path) must correspond to each other. If stopCPUProfiling(Path) is directly called but startCPUProfiling is not called, this exception is thrown.