summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/users_guide/7.12.1-notes.xml12
-rw-r--r--libraries/base/GHC/Conc/Sync.hs4
-rw-r--r--libraries/base/GHC/IO/Exception.hs4
-rw-r--r--libraries/base/System/Mem.hs21
4 files changed, 33 insertions, 8 deletions
diff --git a/docs/users_guide/7.12.1-notes.xml b/docs/users_guide/7.12.1-notes.xml
index b23e3d8e2e..c71887fa28 100644
--- a/docs/users_guide/7.12.1-notes.xml
+++ b/docs/users_guide/7.12.1-notes.xml
@@ -324,6 +324,18 @@
(see Trac #9516).
</para>
</listitem>
+ <listitem>
+ <para>
+ Per-thread allocation counters
+ (<literal>setAllocationCounter</literal> and
+ <literal>getAllocationCounter</literal>) and limits
+ (<literal>enableAllocationLimit</literal>,
+ <literal>disableAllocationLimit</literal> are now
+ available from <literal>System.Mem</literal>.
+ Previously this functionality was only available
+ from <literal>GHC.Conc</literal>.
+ </para>
+ </listitem>
</itemizedlist>
</sect3>
diff --git a/libraries/base/GHC/Conc/Sync.hs b/libraries/base/GHC/Conc/Sync.hs
index 81ec7fabe7..db6f841851 100644
--- a/libraries/base/GHC/Conc/Sync.hs
+++ b/libraries/base/GHC/Conc/Sync.hs
@@ -213,7 +213,9 @@ getAllocationCounter = do
-- to 100K, but tunable with the @+RTS -xq@ option) so that it can handle
-- the exception and perform any necessary clean up. If it exhausts
-- this additional allowance, another 'AllocationLimitExceeded' exception
--- is sent, and so forth.
+-- is sent, and so forth. Like other asynchronous exceptions, the
+-- 'AllocationLimitExceeded' exception is deferred while the thread is inside
+-- 'mask' or an exception handler in 'catch'.
--
-- Note that memory allocation is unrelated to /live memory/, also
-- known as /heap residency/. A thread can allocate a large amount of
diff --git a/libraries/base/GHC/IO/Exception.hs b/libraries/base/GHC/IO/Exception.hs
index e723ebdf33..7e483deea1 100644
--- a/libraries/base/GHC/IO/Exception.hs
+++ b/libraries/base/GHC/IO/Exception.hs
@@ -98,8 +98,8 @@ instance Show Deadlock where
-----
-- |This thread has exceeded its allocation limit. See
--- 'GHC.Conc.setAllocationCounter' and
--- 'GHC.Conc.enableAllocationLimit'.
+-- 'System.Mem.setAllocationCounter' and
+-- 'System.Mem.enableAllocationLimit'.
--
-- @since 4.8.0.0
data AllocationLimitExceeded = AllocationLimitExceeded
diff --git a/libraries/base/System/Mem.hs b/libraries/base/System/Mem.hs
index a894f4d343..c47a52d2f7 100644
--- a/libraries/base/System/Mem.hs
+++ b/libraries/base/System/Mem.hs
@@ -1,5 +1,3 @@
-{-# LANGUAGE Safe #-}
-
-----------------------------------------------------------------------------
-- |
-- Module : System.Mem
@@ -14,17 +12,30 @@
--
-----------------------------------------------------------------------------
+{-# LANGUAGE Trustworthy #-}
+-- allocation counter stuff is safe, but GHC.Conc.Sync is Unsafe
+
module System.Mem
- ( performGC
+ (
+ -- * Garbage collection
+ performGC
, performMajorGC
, performMinorGC
+
+ -- * Allocation counter and limits
+ , setAllocationCounter
+ , getAllocationCounter
+ , enableAllocationLimit
+ , disableAllocationLimit
) where
--- | Triggers an immediate garbage collection.
+import GHC.Conc.Sync
+
+-- | Triggers an immediate major garbage collection.
performGC :: IO ()
performGC = performMajorGC
--- | Triggers an immediate garbage collection.
+-- | Triggers an immediate major garbage collection.
--
-- @since 4.7.0.0
foreign import ccall "performMajorGC" performMajorGC :: IO ()