Manage How Your Application Uses Memory
Since the process thread is shared among all the clients, memory is also shared. You should avoid storing much information in memory per request because it can accumulate over concurrent clients and your process can die simply because it runs out of memory. In threaded servers, a thread usually has a separate memory limit thatâs reached long before the whole server process runs out of memory, so only the thread gets terminated instead of the whole process. However, Node.js, being in a single thread, will kill the whole process. Letâs look at a common mistake where memory is overtaxed:
â | â'use strict'â; |
â | |
â | âvarâ express = require(â'express'â); |
â ... |
Get Secure Your Node.js Web Application now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.