Skip to content

Commit

Permalink
fix the memory leakage bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yi-fan-wang committed Jul 13, 2024
1 parent 70bd500 commit 8d33ec3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions bin/bank/pycbc_brute_bank
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ class TriangleBank(object):
({k: params[k][idx] for k in params} for idx in range(total_num))
):
waveform_cache += [return_wf]
pool.close_pool()
del pool

for hp in waveform_cache:
Expand Down
14 changes: 13 additions & 1 deletion pycbc/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def allmap(self, fcn, args):
return results

def map(self, func, items, chunksize=None):
""" Catch keyboard interuppts to allow the pool to exit cleanly.
""" Catch keyboard interupts to allow the pool to exit cleanly.
Parameters
----------
Expand All @@ -113,6 +113,13 @@ def map(self, func, items, chunksize=None):
self.join()
raise KeyboardInterrupt

def close_pool(self):
""" Close the pool and remove the reference
"""
self.close()
self.join()
atexit.unregister(_shutdown_pool)

def _dummy_broadcast(self, f, args):
self.map(f, [args] * self.size)

Expand All @@ -130,6 +137,11 @@ def map(self, f, items):
imap = map
imap_unordered = map

def close_pool(self):
''' Dummy function to be consistent with BroadcastPool
'''
pass

def use_mpi(require_mpi=False, log=True):
""" Get whether MPI is enabled and if so the current size and rank
"""
Expand Down

0 comments on commit 8d33ec3

Please sign in to comment.