在seeing EKG in 24 days of Hackage之后,我尝试在我的一个程序中使用它,但它没有显示我的任何内存分配。
因此,我用一个仅占用内存的示例程序再次尝试:
{-# LANGUAGE OverloadedStrings #-}
module Main where
import System.Remote.Monitoring (forkServer)
import Control.Applicative ((<$>))
import Control.Monad (foldM, forM_)
import Control.Monad.Primitive (PrimMonad, PrimState)
import Data.Vector.Mutable (MVector, replicate, read, write, length)
import Prelude hiding (read, length, replicate)
import Text.Printf
accumBy :: (Functor m, PrimMonad m) => (a -> a -> a) -> MVector (PrimState m) a -> m a
accumBy f v = do
a <- read v 0
foldM (\a i -> do
a' <- f a <$> read v i
write v i a'
return a'
) a [1 .. length v - 1]
main :: IO ()
main = do
forkServer "localhost" 8000
forM_ [1..] $ \n -> do
v <- replicate (n*1024) (n :: Int)
accumBy (+) v >>= printf "%08x\n"程序运行得很好
% ghc --make Temp.hs -rtsopts && ./Temp +RTS -K32mM -RTS
00000400
00001000
00002400
...但是EKG似乎根本没有检测到我的内存使用情况

我做错了什么?
发布于 2012-12-15 07:38:54
您需要使用-T或-t或-S或-s RTS option来收集统计数据,例如:
ghc --make Temp.hs -rtsopts && ./Temp +RTS -T -K32mM -RTShttps://stackoverflow.com/questions/13887575
复制相似问题