I tried putting together a resource pool and HDBC the other day but noticed that the memory keeps rising for each query. I then put together a simple test code using as few functions as possible and got this:
data SQL = SQL (Pool Connection)
check :: SQL -> IO ()
check (SQL pool) = do res <- query' pool "show status like 'Threads_conn%'" []
threadDelay 100000
check (SQL pool)
Whole code: http://upaste.me/40f2229cef7157f
For each recursion of the check function, the program uses more and more memory. Shouldn't the result be garbage collected at a new recursive call or will it stay in memory until the program exits that function in case "we need it"?
./yourprogram +RTS -h
for information about how to do this../program +RTS -H4096K
and as before, the program builds up memory used for each recursive call.performGC
forever
as well...performGC
norforever
solves the issue at hand. I'm starting to think it's an issue with the library HDBC itself. It might also be that since I have a reference to the pool through the threads, the GC doesn't collect the information as wanted.