my code
fn main() {
std::thread::sleep(std::time::Duration::from_secs(10));
loop {
test();
std::thread::sleep(std::time::Duration::from_secs(3));
}
}
struct MyVec {
vec: Vec<i32>,
}
impl Drop for MyVec {
fn drop(&mut self) {
println!("MyVec is being dropped, memory is being released.");
}
}
fn test() {
let mut my_vec = MyVec { vec: Vec::with_capacity(101) };
for i in 0..101 {
my_vec.vec.push(i);
}
println!("{:?}", my_vec.vec.len());
}
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
101
MyVec is being dropped, memory is being released.
But the memory I detected has been continuously increasing
The data is released after the function ends, but why is there growth inside