In this article, I will explore different ways to track all the allocated pointers and free them reliably. The complete code can be downloaded as a git repo: git clone https://ro-che.info/files/2017-08-06-manage-allocated-memory-haskell.git The modules below use the hsc2hs preprocessor; it replaces things like #{peek ...}, #{poke ...}, and #{size ...} with Haskell code. Way 1: traverse the structu