Skip to content

Commit 97f3d21

Browse files
author
Thinh Nguyen
committed
garbage collect openephys objects
1 parent b2bd0ee commit 97f3d21

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

element_array_ephys/ephys_acute.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import numpy as np
55
import inspect
66
import importlib
7+
import gc
78
from decimal import Decimal
89

910
from element_interface.utils import find_root_directory, find_full_path, dict_to_uuid
@@ -326,6 +327,10 @@ def make(self, key):
326327
self.EphysFile.insert([{**key,
327328
'file_path': fp.relative_to(root_dir).as_posix()}
328329
for fp in probe_data.recording_info['recording_files']])
330+
# explicitly garbage collect "dataset"
331+
# as these may have large memory footprint and may not be cleared fast enough
332+
del probe_data, dataset
333+
gc.collect()
329334
else:
330335
raise NotImplementedError(f'Processing ephys files from'
331336
f' acquisition software of type {acq_software} is'

element_array_ephys/ephys_chronic.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import numpy as np
55
import inspect
66
import importlib
7+
import gc
78
from decimal import Decimal
89

910
from element_interface.utils import find_root_directory, find_full_path, dict_to_uuid
@@ -273,6 +274,10 @@ def make(self, key):
273274
self.EphysFile.insert([{**key,
274275
'file_path': fp.relative_to(root_dir).as_posix()}
275276
for fp in probe_data.recording_info['recording_files']])
277+
# explicitly garbage collect "dataset"
278+
# as these may have large memory footprint and may not be cleared fast enough
279+
del probe_data, dataset
280+
gc.collect()
276281
else:
277282
raise NotImplementedError(f'Processing ephys files from'
278283
f' acquisition software of type {acq_software} is'

element_array_ephys/ephys_no_curation.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import numpy as np
55
import inspect
66
import importlib
7+
import gc
78
from decimal import Decimal
89

910
from element_interface.utils import find_root_directory, find_full_path, dict_to_uuid
@@ -325,6 +326,10 @@ def make(self, key):
325326
self.EphysFile.insert([{**key,
326327
'file_path': fp.relative_to(root_dir).as_posix()}
327328
for fp in probe_data.recording_info['recording_files']])
329+
# explicitly garbage collect "dataset"
330+
# as these may have large memory footprint and may not be cleared fast enough
331+
del probe_data, dataset
332+
gc.collect()
328333
else:
329334
raise NotImplementedError(f'Processing ephys files from'
330335
f' acquisition software of type {acq_software} is'

0 commit comments

Comments
 (0)