You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rhino generates bytecode every time a script is compiled, and that bytecode goes into the PermGen nutil the script is no longer used and it gets GCed. In a server with hundreds of node.js scripts running, if each is using a large set of modules such as Express, then we end up with hundreds of megabytes of bytecode sitting in PermGen.
We can drastically reduce the memory usage in large deployments by caching bytecode. For instance:
SHA1 hash each script before compiling it
Check a thread-safe cache to see if the same script has already been compiled
Only compile if the bytecode is not cached
Make the cache use weak / soft / whatever references so that it will be GCed on memory pressure and not grow forever.
The text was updated successfully, but these errors were encountered:
Rhino generates bytecode every time a script is compiled, and that bytecode goes into the PermGen nutil the script is no longer used and it gets GCed. In a server with hundreds of node.js scripts running, if each is using a large set of modules such as Express, then we end up with hundreds of megabytes of bytecode sitting in PermGen.
We can drastically reduce the memory usage in large deployments by caching bytecode. For instance:
The text was updated successfully, but these errors were encountered: