simov / express-admin

MySQL, MariaDB, PostgreSQL, SQLite admin for Node.js
MIT License
1.17k stars 223 forks source link

What about memory leaks? #84

Open ghost opened 9 years ago

ghost commented 9 years ago
Warning: connect.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.
simov commented 9 years ago

I can't remember seeing that error. Are you sure this isn't something used in your own application?

ghost commented 9 years ago

No, I have separate express admin app and log. This message shows up only when NODE_ENV environment variable is set to "production". 2015-06-15 22-43-27 environment variables 2015-06-15 22-44-11 spbushare - c users r2d2 documents programming spbushare - express-admin-cfg-dev settings json -

ghost commented 9 years ago

Here is the one of solutions: http://stackoverflow.com/questions/10760620/using-memorystore-in-production

simov commented 9 years ago

I still don't see what this have to do with express admin. Express Admin uses Express4 which in turn does not use Connect, or am I wrong?

ghost commented 9 years ago

You can reproduce it. Just set NODE_ENV="production" and start Express Admin.

ghost commented 9 years ago

Here is the explanation: https://github.com/expressjs/session#api

simov commented 9 years ago

Got it, ideally the session store should be configurable, but currently it's not.

KhalilKhalaf commented 6 years ago

Ok looks like we can use some properties that can control this behavior: interval, maxAge, cookie, saveUninitialized, resave .. etc

More can be found here: MongoDB fix: connection.session() MemoryStore is not designed for a production environment

Also that there are some hacks around this error, for example:

I had same issue and did a quick research which is worth sharing. Hope it helps!