Where does the memory for large arrays come from?

25 views
Skip to first unread message

Yusi Feng

unread,
Feb 2, 2023, 8:04:31 PM2/2/23
to v8-dev
Hello everyone,

I use javascript to create a large array.
new Array(1024 * 1024 * 10).fill(0)
I'm wondering where the memory for this large array comes from. I printed all the mmap()'s with chromium and almost all of the mmap()'s were shared and appended to a file.

I thought the memory for the array was created by PartitionAlloc and V8 of the renderer process. But every time I create a new array, the gpu process uses mmap to allocate new virtual memory for the same file (fd=502). And the memory space it allocates is smaller than the size of my array.

How to understand shared memory between renderer process and GPU process? Where does the memory for the array come from?

Thanks,
Yusi

Jakob Kummerow

unread,
Feb 3, 2023, 4:32:47 AM2/3/23
to v8-...@googlegroups.com
Large arrays are allocated on V8's managed heap (in "Large Object Space"). You won't see an mmap call for that, because the heap's entire address space is reserved (without committing / reserving the underlying physical memory) in one go up front. When new pages are needed, they are committed with mprotect. The GPU process doesn't know or care about any of that (and can never share large JS arrays with V8); whatever you've been seeing in the GPU process must be some unrelated artifact.


--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-dev/a74d6e3b-0f52-41b5-90be-566c0034fcdan%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages