Haskell (ghc) memory usage at runtime or what am I doing wrong

I wrote a small program, like a specialized HTTP server in haskell, which is not much more complicated than the code below. I am puzzled by memory consumption. Let's say when I run a test made up of the attached code and make a few POST requests containing up to 20 MB of body, the whole program will have a size of VM ~ 800 MB, and that sounds strange. And this space does not return to the system if I leave an instance of such a program without downtime.

What does it mean?


import System.IO
import Network.HTTP.Server
import Network.Socket
import Network.URL


handler :: SockAddr -> URL -> Request String -> IO (Response String)
handler sa url rq = do
  writeFile "/tmp/out" (rqBody rq)
  return $ insertHeader HdrContentLength "0" (respond OK :: Response String)

main = serverWith defaultConfig {srvPort = 2121} handler
+3
source share
1 answer

-, String. ; 20 . ByteString ( Data.ByteString/Data.ByteString.Char8 ByteString).

-, GHC 6.12 . GHC 7.0 , .

+7

Source: https://habr.com/ru/post/1772740/


All Articles