Safe Haskell | None |
---|---|
Language | Haskell2010 |
System.Mem.Experimental
Synopsis
- setGlobalAllocationLimitHandler :: AllocationLimitKillBehaviour -> Maybe (ThreadId -> IO ()) -> IO ()
- data AllocationLimitKillBehaviour
- getAllocationCounterFor :: ThreadId -> IO Int64
- setAllocationCounterFor :: Int64 -> ThreadId -> IO ()
- enableAllocationLimitFor :: ThreadId -> IO ()
- disableAllocationLimitFor :: ThreadId -> IO ()
Documentation
setGlobalAllocationLimitHandler :: AllocationLimitKillBehaviour -> Maybe (ThreadId -> IO ()) -> IO () Source #
Define the behaviour for handling allocation limits.
The default behaviour is to throw an AllocationLimitExceeded
async exception to the thread.
This can be overriden using AllocationLimitKillBehaviour
.
We can set a user-specified handler, which can be run in addition to or in place of the exception. This allows for instance logging on the allocation limit being exceeded, or dynamically determining whether to terminate the thread. The handler is not guaranteed to run before the thread is terminated or restarted.
Note: that if you don't terminate the thread, then the allocation limit gets
removed.
If you wish to keep the allocation limit you will have to reset it using
setAllocationCounter
and enableAllocationLimit
.
data AllocationLimitKillBehaviour Source #
Constructors
KillOnAllocationLimit | Throw a |
DontKillOnAllocationLimit | Do not throw an exception when the allocation limit is exceeded. |
getAllocationCounterFor :: ThreadId -> IO Int64 Source #
Get the allocation counter for a different thread.
Note: this doesn't take the current nursery chunk into account. If the thread is running then it may underestimate allocations by the size of a nursery thread.
setAllocationCounterFor :: Int64 -> ThreadId -> IO () Source #
Set the allocation counter for a different thread.
This can be combined with enableAllocationLimitFor
to enable allocation limits for another thread.
You may wish to do this during a user-specified allocation limit handler.
Note: this doesn't take the current nursery chunk into account. If the thread is running then it may overestimate allocations by the size of a nursery thread, and trigger the limit sooner than expected.
enableAllocationLimitFor :: ThreadId -> IO () Source #
Enable allocation limit processing the thread t
.
disableAllocationLimitFor :: ThreadId -> IO () Source #
Disable allocation limit processing the thread t
.