Skip to content

Memory use trait / methods / macros #19615

@adriangb

Description

@adriangb

In #19599 we were discussing adding a heap_size() method to Statistics, which requires adding a similar method to all of the structs it references. The idea occurred that there are already crates to handle this sort of thing, namely:

It seems that if we're going to be implementing this for multiple structs it would be nice to at least have a derivable trait and use that trait everywhere.

One choice is between using a 3rd party crate or our own trait. Another choice is what the semantics we want are, the most confusing one perhaps being ref counted pointers (Arc, Rc, etc.).

Having thought about it a bit I think we should go with HeapSize and buff that trait up to provide a macro, implement it for the standard library container types, etc.

That said I'm opening the issue to collect community feedback if anyone has opinions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions