KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
As library docs say CString created with newCString must be freed with free function. I have been expecting that when CString is created it would take some memory and when it is released with free memory usage would go down, but it didn't! Here is example code: module Main where import Foreign import Foreign.C.String import System.IO wait = do putStr "Press enter" >> hFlush stdout _ <- getLine return () main = do let s = concat $ replicate 1000000 ['0'..'9'] cs <- newCString s cs `seq` wait -- (1) free cs wait -- (2) When program stopped at (1), htop program showed that memory usage is somewhere around 410M - this is OK. I press enter and the program stops at line (2), but memory usage is still 410M despite cs has been free d! How is this possible? Similar program written in C behaves as it should. What am I missing here?
Tags (comma-separated)
Save Edits
Cancel