3 ms·
At my work, we have developped `loupe`, a Rust crate that does precisely that, https://github.com/wasmerio/loupe/ https://github.com/wasmerio/loupe/. I'm the ma
by Hywan 5y ago
At my work, we have developped `loupe`, a Rust crate that does precisely that, https://github.com/wasmerio/loupe/ https://github.com/wasmerio/loupe/. I'm the main author of it.
`loupe` provides the `MemoryUsage` trait; It allows to know the size of a value in bytes, recursively. So it traverses most of the types, and its fields or variants as deep as possible. Hopefully, it tracks already visited values so that it doesn't enter an infinite loupe loop.
We are using it inside Wasmer, a WebAssembly runtime.