[英]Why isn't EKG showing my allocated memory?
After seeing EKG in 24 days of Hackage , I tried to use it in one of my programs, but it wasn't showing any of my memory allocation. 在Hackage的24天内看到EKG之后,我试图在我的一个程序中使用它,但它没有显示我的任何内存分配。
So I tried it again with a sample program that just sucks up memory: 所以我再次尝试了一个只吸收内存的示例程序:
{-# 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"
The program runs fine 程序运行正常
% ghc --make Temp.hs -rtsopts && ./Temp +RTS -K32mM -RTS
00000400
00001000
00002400
...
But EKG doesn't seem to be detecting my memory usage at all 但是EKG似乎根本没有检测到我的内存使用情况
What am I doing wrong? 我究竟做错了什么?
您需要使用-T
或-t
或-S
或-s
RTS选项来收集统计信息,例如:
ghc --make Temp.hs -rtsopts && ./Temp +RTS -T -K32mM -RTS
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.