mirror of
https://gitee.com/openharmony/developtools_profiler
synced 2024-11-23 06:50:12 +00:00
!1623 需求,【hidebug】获取应用进程的jsheap内存上限接口
Merge pull request !1623 from zhou_xq/master
This commit is contained in:
commit
fafced73b1
@ -710,12 +710,21 @@ napi_value GetAppMemoryLimit(napi_env env, napi_callback_info info)
|
||||
napi_set_named_property(env, appMemoryLimit, "vssLimit", vssLimit);
|
||||
|
||||
NativeEngine *engine = reinterpret_cast<NativeEngine *>(env);
|
||||
if (engine == nullptr) {
|
||||
return CreateUndefined(env);
|
||||
}
|
||||
napi_value vmHeapLimit;
|
||||
uint64_t vmHeapLimitValue = engine->GetHeapLimitSize();
|
||||
vmHeapLimitValue = vmHeapLimitValue >> BYTE_2_KB_SHIFT_BITS;
|
||||
napi_create_bigint_uint64(env, vmHeapLimitValue, &vmHeapLimit);
|
||||
napi_set_named_property(env, appMemoryLimit, "vmHeapLimit", vmHeapLimit);
|
||||
|
||||
napi_value vmTotalHeapSize;
|
||||
uint64_t vmTotalHeapSizeValue = engine->GetProcessHeapLimitSize();
|
||||
vmTotalHeapSizeValue = vmTotalHeapSizeValue >> BYTE_2_KB_SHIFT_BITS;
|
||||
napi_create_bigint_uint64(env, vmTotalHeapSizeValue, &vmTotalHeapSize);
|
||||
napi_set_named_property(env, appMemoryLimit, "vmTotalHeapSize", vmTotalHeapSize);
|
||||
|
||||
return appMemoryLimit;
|
||||
}
|
||||
|
||||
|
@ -323,6 +323,7 @@ describe("HidebugJsTest", function () {
|
||||
expect(temp.rssLimit >= BigInt(0)).assertTrue();
|
||||
expect(temp.vssLimit >= BigInt(0)).assertTrue();
|
||||
expect(temp.vmHeapLimit >= BigInt(0)).assertTrue();
|
||||
expect(temp.vmTotalHeapSize >= BigInt(0)).assertTrue();
|
||||
} catch (error) {
|
||||
expect().assertFail();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user