温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/node/v8/GCProfiler
点击访问原文链接

Node v8.GCProfiler class | API Reference | Bun

Node v8.GCProfiler class | API Reference | BunBuildDocsReferenceGuidesBlogDiscord/node:v8/GCProfilerM[Symbol.dispose]CoconstructorMstartMstop

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/node:v8/GCProfilerM[Symbol.dispose]CoconstructorMstartMstop

class

v8.GCProfilerclass GCProfiler

This API collects GC data in current thread.

[Symbol.dispose](): void;

Stop collecting GC data, and discard the profile.

start(): void;

Start collecting GC data.

{ console.log(profiler.stop()); }, 1000); ```" data-algolia-static="false" data-algolia-merged="false" data-type="Method">stop(): GCProfilerResult;

Stop collecting GC data and return an object. The content of object is as follows.

{
"version": 1,
"startTime": 1674059033862,
"statistics": [
{
"gcType": "Scavenge",
"beforeGC": {
"heapStatistics": {
"totalHeapSize": 5005312,
"totalHeapSizeExecutable": 524288,
"totalPhysicalSize": 5226496,
"totalAvailableSize": 4341325216,
"totalGlobalHandlesSize": 8192,
"usedGlobalHandlesSize": 2112,
"usedHeapSize": 4883840,
"heapSizeLimit": 4345298944,
"mallocedMemory": 254128,
"externalMemory": 225138,
"peakMallocedMemory": 181760
},
"heapSpaceStatistics": [
{
"spaceName": "read_only_space",
"spaceSize": 0,
"spaceUsedSize": 0,
"spaceAvailableSize": 0,
"physicalSpaceSize": 0
}
]
},
"cost": 1574.14,
"afterGC": {
"heapStatistics": {
"totalHeapSize": 6053888,
"totalHeapSizeExecutable": 524288,
"totalPhysicalSize": 5500928,
"totalAvailableSize": 4341101384,
"totalGlobalHandlesSize": 8192,
"usedGlobalHandlesSize": 2112,
"usedHeapSize": 4059096,
"heapSizeLimit": 4345298944,
"mallocedMemory": 254128,
"externalMemory": 225138,
"peakMallocedMemory": 181760
},
"heapSpaceStatistics": [
{
"spaceName": "read_only_space",
"spaceSize": 0,
"spaceUsedSize": 0,
"spaceAvailableSize": 0,
"physicalSpaceSize": 0
}
]
}
}
],
"endTime": 1674059036865
}

Here's an example.

import { GCProfiler } from 'node:v8';
const profiler = new GCProfiler();
profiler.start();
setTimeout(() => {
console.log(profiler.stop());
}, 1000);

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicense

Baked with ❤️ in San Francisco

We're hiring →

Node v8.GCProfiler class | API Reference | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    This API collects GC data in current thread.