Skip to main content

Buffer

Limitation​

Node.js Buffer objects hold raw bytes in memory. The runtime limits how much memory one allocation can request, so validate it before accepting an unbounded input size.

Real Use Case​

When fetching large Redis objects, the Node.js client receives bytes from a network socket into a Buffer. Retrieving an object larger than the available memory can terminate the process.

Buffer.alloc - Limitations​

When working with NodeJS buffer allocation - there's a constant buffers.constants.MAX_LENGTH which tells you, in bytes, what is the maximum alloc you can have.

Share: