Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How do I manage memory in node js

How do I manage memory in node js

Problem

I'm writing a node.js software module which stores a number of strings of varying length in an object map. This is essentially serving as a in memory cache for my overall software.

I was wondering how do I account for the fact that more memory will be used up the longer my application is running and I understand node processes by default have a memory limit imposed by the v8 engine.

I have already put in place code which after a certain time removes old cache entries but this does not protect against a lot of cache entries being placed in a short amount of time.

Problem courtesy of: user2220365

Solution

As dm03514 says, use a dedicated cache component. Memcached will do this for you, as will Redis.

The main problem you will face is invalidation, both of these allow you to set expiry times for keys.

Solution courtesy of: Joe

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

How do I manage memory in node js

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×