Send LowMemoryNotification before imposing memory limit #222
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.
Currently if you
setMemoryLimitthe timer thread regularly checks the size of the heap and compares it against the limit. If V8's old space is configured to be big (default is 1,5 GB) and a small limit is applied, it might happen that V8 does no garbage collection at all and V8Js considers the limit as hit.This pull request changes the behaviour to first send a
LowMemoryNotificationto V8 in order to force a garbage collection run. If the heap size then is still too big, then execution is terminated.Besides this adds a memory limit check after execution which triggers if execution times are small enough never to be hit by the timer threads 10ms interval.
This fixes #217