When using the Haskell HDBC-ODBC library to connect to Microsoft SQL Server, I experience a bad memory leak.
import Database.HDBC import qualified Database.HDBC.ODBC as ODBC import Control.Monad -- | Main application. main :: IO () main = dbTest dbTest :: IO () dbTest = do let connStr = "DSN=TESTDB;Uid=sa;Pwd=password" conn <- ODBC.connectODBC connStr replicateM_ 20000 (loop conn) disconnect conn where loop c = do result <- getTables c commit c putStrLn $ show result
Running the heap profiler gives me consistent memory usage, but Window's report size grows to almost 100 MB of usage.
http://i.stack.imgur.com/YkUTW.png
It seems to me that the memory leak is in the interface of the external function of the ODBC driver, but this is my first profiling code, so I can not be sure. Does anyone have any further ideas or suggestions for a fix? Calling System.Mem.performGC in a loop to try and clear has no effect.
Are there any alternatives to using HDBC-ODBC? If not, I may need to find out F #.
source share