I'm trying to understand some garbage collection behavior I'm seeing with V8 / Chrome. The scenario is that I have a small program that receives ~ 1MiB of image data from a websocket at a rate of about 60Hz.
Minimal receiving code looks like this:
var connection = new WebSocket('ws://127.0.0.1:31333');
connection.onmessage = message => {
var dataCopy = new Uint8Array(message.data, 0);
};
Profiling in Chrome shows a saw tooth of allocations rising until a major garbage collection occurs, repeating at regular intervals. The allocations are all exactly 176 bytes, which doesn't really match up with the expected 1 MiB. I also took a heap snapshot and dug through it a bit but couldn't see anything useful that was 176 bytes in size.
I found an excellent overview of V8 GC (
https://v8.dev/blog/trash-talk). If I understand
correctly it seems a little surprising that I'm seeing major GC events
when a minor scavenge type GC could probably pick up those allocations.
Additionally, as mentioned above, the allocations seen while profiling
don't have the expected size of 1MiB.
I understand that there's a "large object space" which is possibly where the allocations are actually ending up.
Unfortunately I can't find any references to "large object space" at
https://v8.dev/docs.
Can anyone help me understand:
Why I see this behaviour with major GC's happening regularly?
Why are the allocations smaller than expected?
If it's related to large object handling are there any resources that explain how large objects are handled in V8 / Chrome and
what the limits around them are?
I'm using Chrome Version 81.0.4044.113 (Official Build) (64-bit)) and Windows 10 Pro 1903 if that's helpful.
Thanks
