rts: add "-no-rtsopts-suggestions" option
[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 "Hooks.h"
10 #include "RtsFlags.h"
11 #include <stdio.h>
12
13 void
14 OutOfHeapHook (W_ request_size, W_ heap_size) /* both sizes in bytes */
15 {
16 (void)request_size; /* keep gcc -Wall happy */
17 if (heap_size > 0) {
18 errorBelch("Heap exhausted;");
19 errorBelch("Current maximum heap size is %" FMT_Word
20 " bytes (%" FMT_Word " MB).",
21 heap_size, heap_size / (1024*1024));
22
23 if (rtsConfig.rts_opts_suggestions == rtsTrue) {
24
25 if (rtsConfig.rts_opts_enabled == RtsOptsAll) {
26 errorBelch("Use `+RTS -M<size>' to increase it.");
27 } else {
28 errorBelch("Relink with -rtsopts and "
29 "use `+RTS -M<size>' to increase it.");
30 }
31
32 }
33 } else {
34 errorBelch("Out of memory.\n");
35 }
36 }