函数
func GC(Bool) (deprecated)
public func GC(heavy!: Bool = false): Unit
功能:执行 GC。
注意
未来版本即将废弃,使用gc 替代。
参数:
func gc(Bool)
public func gc(heavy!: Bool = false): Unit
功能:执行 gc。
参数:
func getAllocatedHeapSize()
public func getAllocatedHeapSize(): Int64
功能:获取仓颉堆已被使用的大小,单位为 byte。
返回值:
- Int64 - 仓颉堆已被使用的大小,单位为 byte。
func getBlockingThreadCount()
public func getBlockingThreadCount(): Int64
功能:获取阻塞的仓颉线程数。
返回值:
- Int64 - 阻塞的仓颉线程数。
func getMaxHeapSize()
public func getMaxHeapSize(): Int64
功能:获取仓颉堆可以使用的最大值,单位为 byte。
返回值:
- Int64 - 仓颉堆可以使用的最大值,单位为 byte。
func getNativeThreadCount()
public func getNativeThreadCount(): Int64
功能:获取物理线程数。
返回值:
- Int64 - 物理线程数。
func getProcessorCount()
public func getProcessorCount(): Int64
功能:获取处理器数量。
返回值:
- Int64 - 处理器数量。
func getThreadCount()
public func getThreadCount(): Int64
功能:获取仓颉当前的线程数量。
返回值:
- Int64 - 仓颉当前的线程数量。
func getUsedHeapSize()
public func getUsedHeapSize(): Int64
功能:在 Linux 平台下获取仓颉堆实际占用的物理内存大小, 单位为 byte。在 Windows 及 macOs 平台下获取仓颉进程实际占用的物理内存大小, 单位为 byte。
返回值:
- Int64 - 仓颉堆或仓颉进程实际占用的物理内存大小,单位为 byte。
func SetGCThreshold(UInt64) (deprecated)
public func SetGCThreshold(value: UInt64): Unit
功能:修改用户期望触发 GC 的内存阈值,当仓颉堆大小超过该值时,触发 GC,单位为 KB。
注意
未来版本即将废弃,使用setGCThreshold(UInt64) 替代。
参数:
示例: 设置用户期望的 GC 的内存阈值为 2MB。
import std.runtime.*
main() {
SetGCThreshold(2048)
}
func setGCThreshold(UInt64)
public func setGCThreshold(value: UInt64): Unit
功能:修改用户期望触发 gc 的内存阈值,当仓颉堆大小超过该值时,触发 gc,单位为 KB。
参数:
示例: 设置用户期望的 gc 的内存阈值为 2MB。
import std.runtime.*
main() {
setGCThreshold(2048)
}