Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the meaning of security_token in system, native_context in global in node heap snapshot

I'm searching on the node heap snapshot. And I found security_token in system and native_context in global in the snapshot.

They have a small shallow size and a very large retained size.

So I want to know the details of these.

Anyone who knows this?

capture - chrome heap snapshots

like image 734
MJ M Avatar asked Sep 01 '25 04:09

MJ M


1 Answers

Small intro, Node.js is written in C++ and JS engine V8 is written in the C++ too, so when people say native something in Node.js they usually mean C++ stuff that can be called from the JS code or not and etc.

In that particular case native_context is just the object that stores some fields from the Native side of the Node.js. Even datatypes are C++ entities under the hood and you are operating with these "native" entities.

There is no way you can change or modify the native_context because this thing is defined during the build of the Node.js executable and defined in the C++ code. You can dig up more about these in the Node.js repository in C++ source code if you want to know more about that.

https://github.com/nodejs/node

UPD: You can search it in the code e.g. here is what you can find, but you need to know some C++ to understand.

enter image description here

like image 67
Ayzrian Avatar answered Sep 02 '25 17:09

Ayzrian