Get the current memory usage of a variable?

114 Views Asked by At

I'm new to Rust, and this might be a silly question.

Is it possible to get the current memory usage of a variable?

I am writing a programme that uses a lot of memory (which I'd expect), and I'd like to reduce its memory footprint. However premature optimisation is the root of all evil, so before I start playing around with refactoring, I'd like to see what is currently using memory. When I make a change, I'd like to see if what I've done has reduced the memory footprint at all.

My current programme has lots of HashMaps and so forth, so that's the sort of objects I want to measure.

0

There are 0 best solutions below