Hi Prakash,

I added the AddNearHeapLimitCallback API. The provided callback is invoked
when V8's heap is close to the heap limit specified by the
ResourceConstraints::max_old_space_size during V8 setup.

If the callback extends the heap limit by returning a number greater then
the provided current_heap_limit, then the application will continue running
until the new heap limit is reached. At that point the callback is invoked
again.
If the callback returns the current_heap_limit (or smaller number) then the
application will crash with OOM if it continues allocating.

The initial_heap_limit is the original limit that V8 was set up with. It is
provided for convenience, so that the callback can figure out if it has
already extended the limit without maintaining state.

The callback is called on the same thread as the running JavaScript. So
during callback invocation JavaScript is paused.

Overall, I think the API should work for your case.

Caveats:
- the callback may be invoked multiple times.
- if the callback does not extend the heap limit, then the application is
not guaranteed to OOM. For example, if the application stops allocating and
never reaches the heap limit.
- if the heap limit is extended by small number, then the application may
still crash with OOM. For example, if the application wants to allocate
10MB, but the limit is extended by 5MB.
- if V8 runs out of system memory without reaching the heap limit, then it
will crash with OOM without invoking the callback. For example, if
malloc/mmap fails there is no way to safely continue execution.

I hope that answers your questions. Please let me know if I missed anything.

Cheers,
Ulan.

On Tue, Jun 5, 2018 at 11:28 AM, Prakash Bailkeri <
[email protected]> wrote:

> Thanks for the response.
>
> Any advice on usage of "AddNearHeapLimitCallback"? [Please see my sample
> program]
>
> Thanks, Prakash
>
>
> --
> --
> v8-users mailing list
> [email protected]
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
v8-users mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to