7

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

EKG stats

What am I doing wrong?

rampion
  • 87,131
  • 49
  • 199
  • 315

1 Answers1

11

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
Fedor Gogolev
  • 10,391
  • 4
  • 30
  • 36
  • 1
    [right there in the documentation](http://hackage.haskell.org/packages/archive/ekg/0.3.1.2/doc/html/System-Remote-Monitoring.html#g:1), doh. – rampion Dec 14 '12 at 23:44