Store Compiled Packet Parsers in a global cache - Resolves #722 #723
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #722 for details
When a connection is closed, any compiled parser created for that will
be lost, as the connection is removed.
However, Node/V8 Internals appear to be holding onto any created function.
This can result in memory leaking based on connection cycling and new
parsers being created again.
This change creates a global cache store since everything around the generated
code is not connection specific.
This also completes a TODO to use an LRU cache, although I set a high value
as to avoid running into the leak if the LRU is too small.
An API is provided for anyone who does need to control the max value, as
well as an API to clear the parser cache.