Add memory_used api and related tools#78
Merged
Conversation
a482be7 to
c39c394
Compare
arthurprs
reviewed
Aug 21, 2025
arthurprs
left a comment
Owner
There was a problem hiding this comment.
Thank you! Do you think exposing the split between map and entries is helpful?
c39c394 to
1608f48
Compare
Contributor
Author
I'm also a bit concerned about this issue. Perhaps another approach would be to add a separate feature, something like "unstable", which by default only allows the use of total(), and then enable this feature in memory_used_plot. |
Owner
|
It might be best to return a single usize. Which I expect to be sufficient for most, if not all use cases. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In practice, it is important to be able to estimate the memory usage of a cache in advance and to monitor its memory consumption in real time. Therefore, the
memory_usedAPI has been added.However, it currently has a few issues:
Vec<T>that is actually allocated on the heap, this calculation will be inaccurate.To verify the accuracy of the calculation, I've added
examples/memory_used_plot.rs. This program plots our estimated memory usage alongside the memory usage of the process as observed at the operating system level. As shown in the figure below, our estimated values are highly accurate.