-
Notifications
You must be signed in to change notification settings - Fork 207
Possible memory leak (?) #35
Copy link
Copy link
Open
Description
Hello! I won't bother you. I think the function syscall_getrusage() in the main may be a source of a memory leak, due to the Box::into_raw. The Box::from_raw(ptr) nor explicit drop release it in the code.
fn syscall_getrusage() {
let time = libc::timeval {
tv_sec: 0,
tv_usec: 0,
};
let rusage = Box::new(libc::rusage {
ru_utime: time,
ru_stime: time,
ru_maxrss: 0,
....
});
let ptr = Box::into_raw(rusage); // Ownership forgotten, no drop instruction
let result = benchmark(
|| {},
|_test| {
unsafe {
libc::getrusage(0, ptr);
}
true
},
)
.unwrap();
result.print_results("Sycall getrusage(2)", 0);
}Probably invoking the from_raw after that test would be a good choice? Because running napkin_math --evaluate syscall_getrusage -n 1000000 may consume a lot of memory. Probably I'm wrong but what do you think?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels