Merge branch 'master' of darcs.haskell.org:/home/darcs/ghc
[ghc.git] / rts / hooks / OutOfHeap.c
1 /* -----------------------------------------------------------------------------
2 *
3 * User-overridable RTS hooks.
4 *
5 * ---------------------------------------------------------------------------*/
6
7 #include "PosixSource.h"
8 #include "Rts.h"
9 #include <stdio.h>
10
11 void
12 OutOfHeapHook (lnat request_size, lnat heap_size) /* both sizes in bytes */
13 {
14 /* fprintf(stderr, "Heap exhausted;\nwhile trying to allocate %lu bytes in a %lu-byte heap;\nuse `+RTS -H<size>' to increase the total heap size.\n", */
15
16 (void)request_size; /* keep gcc -Wall happy */
17 if (heap_size > 0) {
18 errorBelch("Heap exhausted;\nCurrent maximum heap size is %" FMT_SizeT " bytes (%" FMT_SizeT " MB);\nuse `+RTS -M<size>' to increase it.",
19 heap_size, heap_size / (1024*1024));
20 } else {
21 errorBelch("out of memory");
22 }
23 }
24