Copyright | (C) 2015 Edward Kmett |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | experimental |
Portability | GHC |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
This module supplies a variant of the selfish form of "Poor Richard's Memory Manager" by Hertz, Kane, Keudel, Bai, Ding, Gu and Bard, adapted to run in Haskell in user-space.
Usage:
main = do
_ <- selfishManager
...
Now, the background thread that was spawned by selfishManager
will watch for signs that the host operating system
is starting to cause the current process to page out to disk and respond with more aggressive garbage collection.
This empowers your code to try to avoid the inevitable death spiral that follows when GC has to happen with paged out data.
Memory Manager
selfishManager :: IO ThreadId Source
Run a background thread that checks for signs of memory pressure from the Host OS and kickstarts a garbage collection as needed.
Statistics and Utilities
currentResidentSetSize :: IO CSize Source
Retrieve the current resident set size for the currently executing program.
peakResidentSetSize :: IO CSize Source
Retrieve the current peak resident set size for the currently executing program.
hardPageFaults :: IO CSize Source
Return the total number of "hard page-faults" since the program started. These are page-faults which required us to go out to disk.
checkMemoryPressure :: IO Bool Source
Determine if memory pressure warrants further action.
This will return True
if we are getting signs from the operating system that we should reign in our memory usage.
cumulativeManagedCollections :: IO Int Source
Return the total number of managed collections that the GC manager has forced.