[Haskell-beginners] storage leak in NetSNMP?

Lieven Marchand lieven.marchand at gmail.com
Mon Oct 21 09:35:15 UTC 2013


Hi,

I have a small script that computes a list of network devices, directs an 
SNMP query at each of them, computes a report from the result of that query 
and prints that. I would expect that to run in constant space but instead 
memory usage keeps going up until the script is killed by the OOM killer.

Is it possible that the NetSNMP library is keeping hold of all the results 
of its session?

Here's part of my code:

analyzeSNMP :: Line -> IO()
analyzeSNMP x = do 
  snmp <- getSNMP x
  putStrLn $ getNetworks (x, snmp)

getSNMP :: Line -> IO (Either String [SnmpResult])
getSNMP line = snmpWalk snmp_version_2c (encodeUtf8 (primaryRouterLoopback   
line)) (DBC.pack "XXX") mib2

getNetworks :: (Line, Either String [SnmpResult]) -> String


main = do
  initialize
  args <- arguments
  wans <- case wanInventoryFileName args of
            Just s -> parseWANInventory s
            Nothing -> return DefaultWAN.wans
  let lines = makeLines (tail wans)
  mapM_ analyzeSNMP lines



More information about the Beginners mailing list