Hi Deepti,

Thanks for your response.

On Wed, Sep 12, 2018 at 7:32 PM, 'Deepti Gandluri' via v8-users <
v8-users@googlegroups.com> wrote:

> If you are looking to track Wasm allocations, there is a counter on the
> Isolate that wasm memory allocations are registered
> <https://cs.chromium.org/chromium/src/v8/src/wasm/wasm-memory.cc?q=wasm-memory.cc&sq=package:chromium&dr&l=153>
> with - V8.WasmAddressSpaceUsageMiB. The page allocator is the catch all for
> allocations, so that should work too.
>
> For GetHeapStatistics
> <https://cs.chromium.org/chromium/src/v8/src/api.cc?dr&q=GetHeapSta&sq=package:chromium&g=0&l=8365>(),
> WasmMemory is accounted for under malloced memory, could you elaborate on
> the discrepancies that you are seeing?
>

In real tests, I observe that malloced_memory is always 8192. Even after
creating a large WebAssembly.Memory object and populating it,
malloced_memory continues to return 8192. I'm not sure what this stat
tracks, exactly, but it makes sense that it wouldn't count
WebAssembly.Memory backing buffers since they are presumably not allocated
with malloc().

It looks like external_memory() was recently added, and this actually
measures WASM memory, which solves my problem. (And it looks like while I
wait for external_memory() to land in stable, I can call
AdjustAmountOfExternalAllocatedMemory(0) as an alternative way to get the
same information.)


> Ideally, Memory.Grow should honor the same resource constraints that a
> JSArrayBuffer allocation does, because it either adjusts the externally
> allocated memory,
> <https://cs.chromium.org/chromium/src/v8/src/wasm/wasm-objects.cc?dr&q=GrowMem&sq=package:chromium&g=0&l=911>
> or allocates a new ArrayBuffer. The WasmMemoryTracker tracks wasm
> allocations
> <https://cs.chromium.org/chromium/src/v8/src/wasm/wasm-memory.cc?dr&q=wasm-memory.cc&sq=package:chromium&g=0&l=29>,
> apart from the isolate counters, there is no public API for the WasmEngine
> right now.
>

For now I've implemented a "patrolling" technique, where I kill an isolate
after the fact if it uses too much memory. It would be great if a limit on
external memory were added to ResourceConstraints and enforced upfront. If
I find time I'll look into adding this and submitting a patch.

-Kenton

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

Reply via email to