Memory Management

Modern programming languages that we work with these days have made memory management simpler that ever, they manage it on their own using things like garbage collectors, smart pointers, ownership, etc. Creating an empty vector is as simple as let empty_vec: Vec<i32> = Vec::new(); But some questions remain unanswered if you haven’t tried manually doing memory operations like: how is a sized vector created using Vec::with_capacity? how is a vector resized on calling pop_back or push_back?...

September 8, 2024 · 7 min · 1419 words · Lakshya Singh