Skip to content

Commit

Permalink
Merge pull request #240 from LSSTDESC/u/joezuntz/gc-collect
Browse files Browse the repository at this point in the history
Add garbage collection to loop in CatEstimator
  • Loading branch information
sschmidt23 authored Sep 1, 2022
2 parents 2454fc1 + 4755543 commit ec3d79c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rail/estimation/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from rail.core.data import TableHandle, QPHandle, ModelHandle
from rail.core.stage import RailStage

import gc

class CatEstimator(RailStage):
"""The base class for making photo-z posterior estimates from catalog-like inputs
Expand Down Expand Up @@ -100,6 +100,9 @@ def run(self):
print(f"Process {self.rank} running estimator on chunk {s} - {e}")
self._process_chunk(s, e, test_data, first)
first = False
# Running garbage collection manually seems to be needed
# to avoid memory growth for some estimators
gc.collect()
self._finalize_run()

def _initialize_run(self):
Expand Down

0 comments on commit ec3d79c

Please sign in to comment.