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.
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
What am I doing wrong?
You need to use -T
or -t
or -S
or -s
RTS option for collecting statistics, e.g.:
ghc --make Temp.hs -rtsopts && ./Temp +RTS -T -K32mM -RTS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With