Looking at the code, it looks like --wasm_max_mem_pages limits the size of 
a particular Memory object, but a script can always allocate multiple 
objects / create multiple instances. I need to limit the script's total 
memory usage...

I do need to track and limit per-isolate. But maybe I can use PageAllocator 
combined with keeping track of the current isolate using thread-locals? Or 
might it be called in background threads?

-Kenton

On Tuesday, September 11, 2018 at 11:19:13 AM UTC-7, Ben Noordhuis wrote:
>
> On Tue, Sep 11, 2018 at 6:34 PM, 'Kenton Varda' via v8-users 
> <[email protected] <javascript:>> wrote: 
> > Hi v8-users, 
> > 
> > I noticed that WASM seems to ignore the ResourceConstraints I've set on 
> my 
> > isolate -- a WebAssembly.Memory object can grow to far beyond the heap 
> > constraint I've set, and I don't see any constraint specific to WASM. 
> The JS 
> > code can, of course, specify a maximum memory limit when creating the 
> Memory 
> > object, but that's an API exposed to the script. As as embedder, I need 
> to 
> > enforce my own constraint. 
> > 
> > Relatedly, it appears that GetHeapStatistics() does not include WASM 
> memory 
> > in the counts. As an embedder I need to keep track of the memory an 
> isolate 
> > has allocated. 
> > 
> > I've searched through v8.h and haven't been able to find any alternate 
> APIs 
> > for these. Is there one I missed, or is this something I'll need to add 
> > myself? 
> > 
> > -Kenton 
>
> You should be able to control it with the `--wasm_max_mem_pages=...` 
> flag (expressed in multiples of 64k) that you can set with 
> `v8::V8::SetFlagsFromString()`.  I don't think there is currently any 
> other way to configure it. 
>
> WASM allocations should be observable when you return a custom 
> `v8::PageAllocator*` from `v8::Platform::GetPageAllocator()`.  Maybe 
> not ideal but hopefully workable. 
>
> You can probably also limit memory growth that way, by returning 
> nullptr when it's past a threshold, although not on a per-isolate 
> basis. 
>

-- 
-- 
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