script: Add basic memory pressure reporting to SpiderMonkey (#42180)

By reporting memory usage of rust objects back to SM it can trigger GC
sooner and release more memory (I hope that we could use this to avoid
OOB in webgpu in the future).

Currently we use simple `size_of::<DomStruct>() +
size_of::<Box<DomStruct>>()` but it's possible to override reported
memory with `update_memory_size(self, nbytes);` on reflector. This is
mostly useful for canvases and buffers which usually have large
associated data.

Testing: None, but I am wondering if we can connect this to
`about:memory`.
Fixes: #42168

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
Sam
2026-01-30 19:11:06 +01:00
committed by GitHub
parent db052c4990
commit 8ed35f1ce9
29 changed files with 171 additions and 25 deletions

View File

@@ -69,6 +69,8 @@ impl Drop for GPUCommandBuffer {
self.command_buffer.0, e
);
}
let reflector = script_bindings::reflector::DomObject::reflector(self);
reflector.drop_memory(self);
}
}