Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't EKG showing my allocated memory?

Tags:

haskell

ekg

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?

like image 348
rampion Avatar asked Dec 14 '12 23:12

rampion


1 Answers

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
like image 133
Fedor Gogolev Avatar answered Nov 08 '22 12:11

Fedor Gogolev