Skip to content

Commit 73cecc8

Browse files
Explicitly drop parser in order to free memory
1 parent 3061047 commit 73cecc8

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

readstat/src/rs_data.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,16 @@ impl ReadStatData {
160160

161161
// setup parser
162162
// once call parse_sas7bdat, iteration begins
163-
let error = ReadStatParser::new()
163+
let mut parser = ReadStatParser::new()
164164
// do not set metadata handler nor variable handler as already processed
165165
.set_value_handler(Some(cb::handle_value))?
166166
.set_row_limit(Some(self.batch_rows_to_process.try_into().unwrap()))?
167-
.set_row_offset(Some(self.batch_row_start.try_into().unwrap()))?
168-
.parse_sas7bdat(ppath, ctx);
167+
.set_row_offset(Some(self.batch_row_start.try_into().unwrap()))?;
168+
169+
let error = parser.parse_sas7bdat(ppath, ctx);
170+
171+
// drop parser after finished
172+
drop(parser);
169173

170174
match FromPrimitive::from_i32(error as i32) {
171175
Some(ReadStatError::READSTAT_OK) => Ok(()),

readstat/src/rs_parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl ReadStatParser {
133133
}
134134

135135
pub fn parse_sas7bdat(
136-
self,
136+
&mut self,
137137
path: *const c_char,
138138
user_ctx: *mut c_void,
139139
) -> readstat_sys::readstat_error_t {

0 commit comments

Comments
 (0)