I'd like to limit the size of the heap used by an Isolate. However, the granularity of ResourceConstraints::set_max_old_space_size is MB, and I need finer grained control than that. Is there any practical way to track and/or limit the heap size with a granularity of KB? I'd like to limit the heap size to some tens of KB above the baseline of what is needed to create an Isolate and Context.
I've thought of: * Using AddGCPrologueCallback or AddGCEpilogueCallback along with GetHeapStatistics to periodically check the heap size. If the used_heap_size() is above the desired limit then I call isolate->TerminateExecution(). The problem with this is that the GC happens infrequently, and when the heap size is already way beyond my desired limit. * From a separate watchdog thread, use Locker along with Isolate::GetHeapStatistics() to periodically check the heap size. The problem with this approach is that I don't think you can get the required lock (using Locker) from a separate thread while JavaScript code is executing in the Isolate. Also, I'm concerned about trying to figure out the correct accuracy/overhead tradeoff of doing it this way. If I poll frequently then I'm spending a lot of CPU cycles checking the heap size. If I poll infrequently then I'm not able to effectively enforce the heap size limit. * Some other callback that fires frequently during JavaScript execution that I could hook into. So far I haven't found a callback that would fire regularly and frequently. I'm interested in any suggestions on how to enforce a more granular heap size limit. Thanks, Chris -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.