Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does Node.js store buffers?

The Node.js documentation on Buffer says:

Raw data is stored in instances of the Buffer class. A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.

Okay, so buffers are not stored in the V8 heap, but… where does Node.js actually store them? I can hardly imagine that it's on the stack, is it?

In other words: What exactly does

a raw memory allocation outside the V8 heap

actually mean?

like image 321
Golo Roden Avatar asked Jul 15 '15 11:07

Golo Roden


People also ask

How does the buffer store data in node JS?

A buffer is a space in memory (typically RAM) that stores binary data. In Node. js, we can access these spaces of memory with the built-in Buffer class. Buffers store a sequence of integers, similar to an array in JavaScript.

How does MongoDB store buffers?

MongoDB actually stores buffers in a special Binary class. A MongoDB binary is just a wrapper around a buffer with an additional sub_type property that is useful for UUIDs. For the purposes of this article though, you can ignore the sub_type property and just use the buffer property to get a Node. js buffer.

Where are node js files stored?

You put them in whatever folder you want. It is common practice to put each application in a different folder.

What is buffer object Nodejs?

The buffers module provides a way of handling streams of binary data. The Buffer object is a global object in Node. js, and it is not necessary to import it using the require keyword.


1 Answers

out side of v8 heap area. read the below link will help you.

https://nodejs.org/api/smalloc.html#smalloc_smalloc

like image 121
Nalla Srinivas Avatar answered Oct 16 '22 02:10

Nalla Srinivas