服务 / DebugService
DebugService Class
Instance
debug调试服务
Table of contents
Methods
getHeapStatistics(): HeapStatistics |
---|
获取当前项目所有TS脚本内存占用 |
Methods
getHeapStatistics
• Static
getHeapStatistics(): HeapStatistics
获取当前项目所有TS脚本内存占用
Returns
HeapStatistics | HeapStatistics 内存数据 |
---|
ts
@Component
export default class DebugExample extends Script {
protected onStart(): void {
TimeUtil.setInterval(() => {
const heapStatistics = DebugService.getHeapStatistics();
console.log("---------当前ts内存使用情况---------");
console.log("总堆大小", heapStatistics.totalHeapSize);
console.log("可执行的总堆大小", heapStatistics.totalHeapSizeExecutable);
console.log("已使用堆大小", heapStatistics.usedHeapSize);
console.log("动态分配的内存", heapStatistics.memoryAllocated ? heapStatistics.memoryAllocated : 0);
console.log("动态内存分配峰值 ", heapStatistics.peakMemoryAllocated ? heapStatistics.peakMemoryAllocated : 0);
}, 2);
}
}
@Component
export default class DebugExample extends Script {
protected onStart(): void {
TimeUtil.setInterval(() => {
const heapStatistics = DebugService.getHeapStatistics();
console.log("---------当前ts内存使用情况---------");
console.log("总堆大小", heapStatistics.totalHeapSize);
console.log("可执行的总堆大小", heapStatistics.totalHeapSizeExecutable);
console.log("已使用堆大小", heapStatistics.usedHeapSize);
console.log("动态分配的内存", heapStatistics.memoryAllocated ? heapStatistics.memoryAllocated : 0);
console.log("动态内存分配峰值 ", heapStatistics.peakMemoryAllocated ? heapStatistics.peakMemoryAllocated : 0);
}, 2);
}
}