Skip to content

ghci leaks memory when loading a file

In the 6.12 series, ghci leaks memory when loading definitions. This appears to be a regression from previous releases. The problem appears in both 6.12.1 and 6.12.2, but not in 6.8.3 or 6.10.4.

As a test, take the attached Hello World file, fire up ghci, and :load Hello.hs. Watch the memory usage of ghci---each time you repeat the load command, the memory usage of the process grows. (It grows slowly on this simple example, but on a real project, the growth can be several megabytes per :load.)

I discovered this due to my workflow. When programming Haskell, I typically use emacs with haskell-mode, and frequently reload the definitions of the code I am working on. After upgrading to 6.12.1, after coding for some time, I noticed my 8GB machine was swapping. (It is faster to :reload the file rather than :load, and reloading doesn't appear to suffer from the memory leak, but sometimes I switch between modules and :reload is not applicable.)

My workaround for now is to regularly restart my ghci processes to prevent their memory usage from growing so much that my system starts swapping.

I have observed this bug on 32- and 64-bit GHCi on various versions of Ubuntu, on both Intel and AMD processors.

Trac metadata
Trac field Value
Version
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component GHCi
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information