v8 supports optional notification "LowMemoryNotification". Call to this method causes proper garbage collection, so many object will be collected on both js and java sides.
In my experience "IdleNotificationDeadline(now+0.1)" is not enough to collect all objects and some times this could lead to huge memory leak (actually it is not leak, because memory in java heap will be freed after gc in v8, for example if I call js heap snapshot creation)
I suggest, that we should add "LowMemoryNotification" call in case of:
- in case OutOfMemoryError in classes, which already handles this exception
- preventive check free heap size (Runtime.getRuntime().freeMemory()) and call when it is low.