-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Poor Richard's Memory Manager
--   
--   This package implements a form of <a>Poor Richard's Memory Manager</a>
--   by Hertz, Kane, Keudel, Bai, Ding, Gu and Bard in user-space in GHC.
--   
--   Usage:
--   
--   <pre>
--   import System.Mem.Manager
--   main = do
--     _ &lt;- selfishManager
--     ...
--   </pre>
--   
--   Now, the background thread that was spawned by <tt>selfishManager</tt>
--   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.
@package gc
@version 0.0.2


-- | This module supplies a variant of the selfish form of <a>"Poor
--   Richard's Memory Manager"</a> by Hertz, Kane, Keudel, Bai, Ding, Gu
--   and Bard, adapted to run in Haskell in user-space.
--   
--   Usage:
--   
--   <pre>
--   main = do
--     _ &lt;- <a>selfishManager</a>
--     ...
--   </pre>
--   
--   Now, the background thread that was spawned by <a>selfishManager</a>
--   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.
module System.Mem.Manager

-- | Run a background thread that checks for signs of memory pressure from
--   the Host OS and kickstarts a garbage collection as needed.
selfishManager :: IO ThreadId

-- | Retrieve the current resident set size for the currently executing
--   program.
currentResidentSetSize :: IO CSize

-- | Retrieve the current peak resident set size for the currently
--   executing program.
peakResidentSetSize :: IO CSize

-- | Return the total number of "hard page-faults" since the program
--   started. These are page-faults which required us to go out to disk.
hardPageFaults :: IO CSize

-- | Determine if memory pressure warrants further action.
--   
--   This will return <a>True</a> if we are getting signs from the
--   operating system that we should reign in our memory usage.
checkMemoryPressure :: IO Bool

-- | Return the total number of managed collections that the GC manager has
--   forced.
cumulativeManagedCollections :: IO Int
