Frage

I'm learning the vty-ui library. For the following code segment:

main :: IO ()
main = do
  coll <- newCollection
  (ui1, fg1) <- mkFirstUI

  switchToFirst <- addToCollection coll ui1 fg1

My question is: how to delete the switchToFirst ? My program needs to constantly create similar object of the switchToFirst type and I don't want to keep them in memory once used. But in the vty-ui library I can't find a release function.

War es hilfreich?

Lösung

Better than triggering a garbage collection, which GHC does when needed, and you can force it with

System.Mem.performGC

you may prevent the task from growing unlimitedly by capping the heap max size with

+RTS -Msize

as listed in the users guide RTS options to control the garbage collector

Check this GHC advice area for improving memory efficiency.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top