[GHC] #10812: High memory usage

GHC ghc-devs at haskell.org
Sat Aug 29 22:34:14 UTC 2015


#10812: High memory usage
---------------------------------+-----------------------------------------
        Reporter:  danilo2       |                   Owner:
            Type:  bug           |                  Status:  closed
        Priority:  high          |               Milestone:
       Component:  Compiler      |                 Version:  7.10.2
      Resolution:  wontfix       |                Keywords:
Operating System:  MacOS X       |            Architecture:  x86_64 (amd64)
 Type of failure:  None/Unknown  |               Test Case:
      Blocked By:                |                Blocking:
 Related Tickets:                |  Differential Revisions:
---------------------------------+-----------------------------------------

Comment (by danilo2):

 Hello @bgamari! Thank you for your response :)

 I've tried running {{{performGC}}} manually (please look again in my code
 - I've tried all the versions above). Unfortunately even running it,
 nothing happens, the program consumes the same amount of RAM unless it
 terminates.

 Additionally I've tried such variant:

 {{{
 {-# LANGUAGE NoMonomorphismRestriction #-}

 import System.Mem.Weak
 import Control.Concurrent
 import System.Mem

 data Tst a = Tst a deriving (Show, Eq)

 tst a = do
     let arr = [0 .. a*a*a]
         v = Tst (seq arr arr)
     ptr <- mkWeakPtr v Nothing
     return ptr

 xmain = do
     ptrs <- mapM tst [1..100000000]
     performGC
     threadDelay 1000000
     xr <- mapM deRefWeak ptrs
     print $ length $ filter (/= Nothing) xr

     threadDelay 10000000

     return ()

 main = do
     print "A"
     xmain
     print "B"
     xmain
 }}}

 I wanted to check how the program behaves when allocating again some
 resources, so I run {{{xmain}}} two times. What's interesting is that the
 memory is still not released and during second execution the amount of RAM
 used by it exceeds 21 Gb - so it allocates further resources.

 So I've got 2 questions:
 1) Maybe it is Mac OS X related bug?
 2) You've told me that GC is performed only when memory is allocated, so
 when we are performing {{{MapM}}} ten million times, allocating each time
 a small chunk of memory (and returning weak pointers only), shouldn't the
 GC be called at last several times then?

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10812#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list