Buffer
Limitation
NodeJS buffer
module has a constant - that can change due to the environment, OS, etc - as to how much memory a Buffer.alloc
can allocate. It's a good practice to check for this whenever using Buffer class.
Real Use Case
Fetching big objects from Redis - NodeJS redis Library uses the Buffer class when reading the socket responses. If we decide to retrieve a big object from Redis, lets say > 2GB (read below), we can easily kill the NodeJS 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.