mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-08 08:44:37 +08:00
process.memoryUsage() reported external and arrayBuffers as 0. arrayBuffers is now the storage of the ArrayBuffers, typed arrays, Buffers, DataViews and SharedArrayBuffers the program holds, and external the same storage without SharedArrayBuffers, as Node splits them. A view over existing storage adds nothing. v8.getHeapStatistics().external_memory reads the same figure as external. Each ScrBytes owner records the bytes it counts in the struct's padding, so ScrBytes stays 64 bytes and the offsets compiled code reads hold; a static assertion pins them. Owners are counted in a per-instance counter, because their reference counts are not atomic and they are released on their instance's thread. Shared storage moves its owner's count to a process-wide atomic counter, since any thread may release it.
6 lines
782 B
Plaintext
6 lines
782 B
Plaintext
- **Process memory:** `process.memoryUsage()` reads `rss` from the operating system and `heapTotal` and `heapUsed` from the runtime's allocator, so the heap figures start near zero and grow as the program allocates.
|
|
`arrayBuffers` is the storage of the ArrayBuffers, typed arrays, Buffers, DataViews and SharedArrayBuffers the program holds, and `external` is the same storage without SharedArrayBuffers, as in Node.
|
|
Node also counts its own startup allocations in both, so a program that holds no such storage reports `0` where Node reports a few megabytes.
|
|
In a program with worker threads, `external` and the non-shared part of `arrayBuffers` count the calling thread's storage.
|
|
The storage comes from the same allocator, so it also counts in `heapTotal` and `heapUsed`.
|