Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import ideas from Servo's malloc_size_of #9

Open
str4d opened this issue Sep 6, 2021 · 0 comments
Open

Import ideas from Servo's malloc_size_of #9

str4d opened this issue Sep 6, 2021 · 0 comments

Comments

@str4d
Copy link
Owner

str4d commented Sep 6, 2021

This crate currently implements a trait-based measurement approach, where trait impls return the amount of memory that their types requested be allocated.

malloc_size_of is an internal component of Servo (that they built to replace their heapsize crate). The primary difference is that the trait takes an allocator argument, so that the allocator can be queried directly for the size of the allocated memory. This prevents under-counting for small or unaligned allocations (in that the allocator might allocate more memory than is requested). However, for some types it requires an API that not all allocators support, and in the absence of that API, it uses the same calculation approach as heapsize and memuse.

We should look over malloc_size_of for useful ideas. In particular, I'd like to make it possible for callers to get "real allocation" results if they have access to an allocator of the correct type, but not require it (as I think the calculation approach can be made accurate enough that for large types the simpler API suffices).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant