question about V8 Stack roots

32 views
Skip to first unread message

theratliter theratliter

unread,
Apr 4, 2023, 11:41:27 AM4/4/23
to v8-users
Hi all ! does anyone know what the "Stack root" means ? the memory hold by stack variable ?飞书20230404-193425.jpg


Ben Noordhuis

unread,
Apr 4, 2023, 3:20:59 PM4/4/23
to v8-u...@googlegroups.com
On Tue, Apr 4, 2023 at 1:41 PM theratliter theratliter
<thera...@gmail.com> wrote:
>
> Hi all ! does anyone know what the "Stack root" means ? the memory hold by stack variable ?

They're live references to GC objects in JS and WASM stack frames. A
JS function's local variables are an example.

theratliter theratliter

unread,
Apr 5, 2023, 6:38:44 AM4/5/23
to v8-users
Thanks, how can get this result ? my test code is as follows.
const { writeHeapSnapshot } = require('v8');
function run() {
const arr = [];
for (let i = 0; i < 10000000; i++) {
arr[i] = i;
}
writeHeapSnapshot('1.heapsnapshot');
// Prevent from GC
JSON.stringify(arr);
}
run();
and the result is as follows.
WechatIMG2.png

Ben Noordhuis

unread,
Apr 5, 2023, 8:39:15 AM4/5/23
to v8-u...@googlegroups.com
Can you explain what exactly you find surprising?

theratliter theratliter

unread,
Apr 5, 2023, 9:51:31 AM4/5/23
to v8-u...@googlegroups.com
I thought i can see "stack roots" in heapsnapshot

Ben Noordhuis <in...@bnoordhuis.nl>于2023年4月5日 周三16:39写道:
Can you explain what exactly you find surprising?

--
--
v8-users mailing list
v8-u...@googlegroups.com
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups "v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/CAHQurc-Uayds0T2uPK%2BERKdQmUEcRigy6omw9th71Yy5y%2BDd1A%40mail.gmail.com.
Message has been deleted
Message has been deleted

theratliter theratliter

unread,
Apr 6, 2023, 6:18:26 AM4/6/23
to v8-users
I find "stack roots" in heapsnapshot in Node.js v16.18.1, i think it is related to V8 Version. Thanks .
Reply all
Reply to author
Forward
0 new messages