Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Fix space leak in Pos.Delegation.Worker #1663

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions node/src/Pos/Delegation/Worker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@ dlgInvalidateCaches
, HasNodeConfiguration
)
=> m ()
dlgInvalidateCaches = do
-- REPORT:ERROR 'reportOrLogE' in delegation worker.
invalidate `catchAny` reportOrLogE "Delegation worker, error occurred: "
delay (sec 1)
dlgInvalidateCaches
dlgInvalidateCaches =
-- When dlgInvalidateCaches calls itself directly, it leaks memory. The
-- reason for that is that reference to dlgInvalidateCaches is kept in
-- memory (by usage of dlgWorkers) and as it is executed it expands
-- indefinitely, hence more and more space is needed to store it. Using fix
-- fixes the problem as it makes dlgInvalidateCaches itself finite in
-- size. Relevant GHC ticket: https://ghc.haskell.org/trac/ghc/ticket/13080
fix $ \loop -> do
-- REPORT:ERROR 'reportOrLogE' in delegation worker.
invalidate `catchAny` reportOrLogE "Delegation worker, error occurred: "
delay (sec 1)
loop
where
invalidate = do
curTime <- microsecondsToUTC <$> currentTime
Expand Down