Fix memory leak in groot and add trace logs#2971
Conversation
Committed-by: siyuanzhang.zsy from Dev container
Committed-by: siyuanzhang.zsy from Dev container
interactive_engine/executor/store/groot/src/db/storage/rocksdb.rs
Outdated
Show resolved
Hide resolved
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #2971 +/- ##
==========================================
- Coverage 45.07% 42.37% -2.71%
==========================================
Files 99 99
Lines 10660 10649 -11
==========================================
- Hits 4805 4512 -293
- Misses 5855 6137 +282 see 15 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
| unsafe { | ||
| if !self.errMsg.is_null() { | ||
| CString::from_raw(self.errMsg as *mut c_char); | ||
| drop(CString::from_raw(self.errMsg as *mut c_char)); |
There was a problem hiding this comment.
Can remove this unnecessary code.
There was a problem hiding this comment.
This is for fixing the warnings of compiler.
| trace!("closeGraphBackupEngine"); | ||
| unsafe { | ||
| Box::from_raw(ptr); | ||
| drop(Box::from_raw(ptr)); |
There was a problem hiding this comment.
Can drop this unnecessary code
There was a problem hiding this comment.
Similarly, if a point already been wrapped into a Rust struct, e.g. Box, or CString, they will be dropped automatically
There was a problem hiding this comment.
There would be a warning like
warning: unused return value of `std::boxed::Box::<T>::from_raw` that must be used
--> /Users/runner/work/GraphScope/GraphScope/interactive_engine/executor/engine/pegasus/pegasus/src/communication/buffer.rs:121:13
|
121 | Box::from_raw(ptr.as_ptr());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: call `drop(Box::from_raw(ptr))` if you intend to drop the `Box`
= note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
|
121 | let _ = Box::from_raw(ptr.as_ptr());
| +++++++
| unsafe { | ||
| if !self.errMsg.is_null() { | ||
| CString::from_raw(self.errMsg as *mut c_char); | ||
| drop(CString::from_raw(self.errMsg as *mut c_char)); |
What do these changes do?
Related issue number
Fixes #2819