Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] usedHeap() to get a percentage value of currently used heap space #19

Closed
Sv443 opened this issue Feb 9, 2021 · 0 comments · Fixed by #16
Closed

[Feature] usedHeap() to get a percentage value of currently used heap space #19

Sv443 opened this issue Feb 9, 2021 · 0 comments · Fixed by #16
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Sv443
Copy link
Member

Sv443 commented Feb 9, 2021

const v8 = require("v8");
const scl = require("svcorelib");

function usedHeap()
{
	const heapStat = v8.getHeapStatistics();

	const max = heapStat.heap_size_limit;
	const val = heapStat.used_heap_size;

	return scl.mapRange(val, 0, max, 0, 100).toFixed(2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant