@@ -19,6 +19,15 @@ import System.Mem
1919import System.Posix
2020import System.Process
2121
22+#if MIN_VERSION_base(4,11,0)
23+import GHC.Stats (getRTSStatsEnabled, getRTSStats, RTSStats(..), gcdetails_live_bytes, gc)
24+currentBytesUsed :: RTSStats -> Int64
25+currentBytesUsed = fromIntegral . gcdetails_live_bytes . gc
26+#else
27+import GHC.Stats (getGCStats, GCStats(..))
28+getRTSStats = getGCStats
29+#endif
30+
2231-- In initial testing, the minimum live bytes count was 233128 and maximum was
2332-- 363712. Going over the maximum means the test has actually failed - we
2433-- probably have a memory leak; going under the minimum doesn't indicate a
@@ -63,7 +72,7 @@ main = do
6372 let f (!failures, !n) = liftIO $ if n < 3000
6473 then do performMajorGC
6574 threadDelay 5000 -- Wait a bit to allow requestAnimationFrame to call its callback sometimes; this value was experimentally determined
66− gcStats <- getGCStats
75+ gcStats <- getRTSStats
6776 print $ currentBytesUsed gcStats
6877 when (currentBytesUsed gcStats < minBytesAllowed) $ do
6978 putStrLn "FAILED: currentBytesUsed < minBytesAllowed"