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

Document differences from heapsize crate #2

Open
dtolnay opened this issue Feb 17, 2019 · 3 comments
Open

Document differences from heapsize crate #2

dtolnay opened this issue Feb 17, 2019 · 3 comments

Comments

@dtolnay
Copy link

dtolnay commented Feb 17, 2019

The heapsize crate is a popular crate with many crates depending on it and lots of downloads. From the description of deepsize, I can't tell what it would do differently than heapsize. It would be worth calling this out in the readme as well as rustdocs.

@Aeledfyr

@droundy
Copy link

droundy commented Nov 1, 2019

Note also that heapsize is now unmaintained, so it would be nice to be able to locate alternatives that may be better maintained.

@sanmai-NL
Copy link

@Aeledfyr In response to the release notes of 0.2.0, it seems the use case you intend to implement with deepsize is computing total dynamically allocated memory, to the exclusion of statically and automatically allocated memory?

@Aeledfyr
Copy link
Owner

Currently it considers all memory that is directly owned (using Rust's ownership semantics). That means that single owner allocating objects, ie. Box and most collections, are included in the size, while normal references (&T and &mut T) are not counted. Ownership gets ambiguous withe reference counted pointers since there is no single owner that controls the allocation. For Rc and Arc, this counts them once and then tracks them to avoid counting the same memory twice. (Weak variants are not counted).

What do you specifically mean by "statically and automatically allocated memory"?
The current system includes memory on the stack and owned memory on the heap; memory behind non owning references is not counted, so things like static arrays wouldn't be counted.

It's also important to note that this is only and can only be an estimation; without hooking into the allocator it isn't possible to have perfect accuracy in measurements, especially with things like HashMaps that don't expose their capacity or allocation sizes through their public APIs.

(I should probably write out a full justification of this in the docs, but I'm not entirely certain about all of it - there are other valid ways of dealing with reference counting or other shared memory)

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

4 participants