Skip to content

Commit 3fb2c36

Browse files
author
shanedsnyder
authored
Merge pull request #819 from tylerjereddy/treddy_issue_811_part3_cffi_only
BUG: memleak part 3 (CFFI only)
2 parents 40be9a0 + b21d644 commit 3fb2c36

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

darshan-util/pydarshan/darshan/backend/cffi_backend.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,9 @@ def log_get_generic_record(log, mod_name, dtype='numpy'):
350350
if mod_name == 'H5D':
351351
rec['file_rec_id'] = rbuf[0].file_rec_id
352352

353-
clst = np.frombuffer(ffi.buffer(rbuf[0].counters), dtype=np.int64)
354-
flst = np.frombuffer(ffi.buffer(rbuf[0].fcounters), dtype=np.float64)
353+
clst = np.copy(np.frombuffer(ffi.buffer(rbuf[0].counters), dtype=np.int64))
354+
flst = np.copy(np.frombuffer(ffi.buffer(rbuf[0].fcounters), dtype=np.float64))
355+
libdutil.darshan_free(buf[0])
355356

356357
c_cols = counter_names(mod_name)
357358
fc_cols = fcounter_names(mod_name)
@@ -471,7 +472,8 @@ def _log_get_lustre_record(log, dtype='numpy'):
471472
clst = []
472473
for i in range(0, len(rbuf[0].counters)):
473474
clst.append(rbuf[0].counters[i])
474-
rec['counters'] = np.array(clst, dtype=np.int64)
475+
rec['counters'] = np.array(clst, dtype=np.int64, copy=True)
476+
libdutil.darshan_free(buf[0])
475477

476478
# counters
477479
cdict = dict(zip(counter_names('LUSTRE'), rec['counters']))
@@ -594,6 +596,7 @@ def log_get_dxt_record(log, mod_name, reads=True, writes=True, dtype='dict'):
594596
rec['read_segments'] = pd.DataFrame(rec['read_segments'])
595597
rec['write_segments'] = pd.DataFrame(rec['write_segments'])
596598

599+
libdutil.darshan_free(buf[0])
597600
return rec
598601

599602

@@ -636,10 +639,11 @@ def _log_get_heatmap_record(log):
636639
# write/read bins
637640
sizeof_64 = ffi.sizeof("int64_t")
638641

639-
write_bins = np.frombuffer(ffi.buffer(filerec[0].write_bins, sizeof_64*nbins), dtype = np.int64)
642+
write_bins = np.copy(np.frombuffer(ffi.buffer(filerec[0].write_bins, sizeof_64*nbins), dtype = np.int64))
640643
rec['write_bins'] = write_bins
641644

642-
read_bins = np.frombuffer(ffi.buffer(filerec[0].read_bins, sizeof_64*nbins), dtype = np.int64)
645+
read_bins = np.copy(np.frombuffer(ffi.buffer(filerec[0].read_bins, sizeof_64*nbins), dtype = np.int64))
643646
rec['read_bins'] = read_bins
647+
libdutil.darshan_free(buf[0])
644648

645649
return rec

0 commit comments

Comments
 (0)