e89f340430ddf77e7e6504898cc2db6549d35deb
[ghc-hetmet.git] / docs / users_guide / runtime_control.xml
1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <sect1 id="runtime-control">
3   <title>Running a compiled program</title>
4
5   <indexterm><primary>runtime control of Haskell programs</primary></indexterm>
6   <indexterm><primary>running, compiled program</primary></indexterm>
7   <indexterm><primary>RTS options</primary></indexterm>
8
9   <para>To make an executable program, the GHC system compiles your
10   code and then links it with a non-trivial runtime system (RTS),
11   which handles storage management, profiling, etc.</para>
12
13   <para>You have some control over the behaviour of the RTS, by giving
14   special command-line arguments to your program.</para>
15
16   <para>When your Haskell program starts up, its RTS extracts
17   command-line arguments bracketed between
18   <option>+RTS</option><indexterm><primary><option>+RTS</option></primary></indexterm>
19   and
20   <option>-RTS</option><indexterm><primary><option>-RTS</option></primary></indexterm>
21   as its own.  For example:</para>
22
23 <screen>
24 % ./a.out -f +RTS -p -S -RTS -h foo bar
25 </screen>
26
27   <para>The RTS will snaffle <option>-p</option> <option>-S</option>
28   for itself, and the remaining arguments <literal>-f -h foo bar</literal>
29   will be handed to your program if/when it calls
30   <function>System.getArgs</function>.</para>
31
32   <para>No <option>-RTS</option> option is required if the
33   runtime-system options extend to the end of the command line, as in
34   this example:</para>
35
36 <screen>
37 % hls -ltr /usr/etc +RTS -A5m
38 </screen>
39
40   <para>If you absolutely positively want all the rest of the options
41   in a command line to go to the program (and not the RTS), use a
42   <option>&ndash;&ndash;RTS</option><indexterm><primary><option>--RTS</option></primary></indexterm>.</para>
43
44   <para>As always, for RTS options that take
45   <replaceable>size</replaceable>s: If the last character of
46   <replaceable>size</replaceable> is a K or k, multiply by 1000; if an
47   M or m, by 1,000,000; if a G or G, by 1,000,000,000.  (And any
48   wraparound in the counters is <emphasis>your</emphasis>
49   fault!)</para>
50
51   <para>Giving a <literal>+RTS -f</literal>
52   <indexterm><primary><option>-f</option></primary><secondary>RTS option</secondary></indexterm> option
53   will print out the RTS options actually available in your program
54   (which vary, depending on how you compiled).</para>
55
56   <para>NOTE: since GHC is itself compiled by GHC, you can change RTS
57   options in the compiler using the normal
58   <literal>+RTS ... -RTS</literal>
59   combination.  eg. to increase the maximum heap
60   size for a compilation to 128M, you would add
61   <literal>+RTS -M128m -RTS</literal>
62   to the command line.</para>
63
64   <sect2 id="rts-optinos-environment">
65     <title>Setting global RTS options</title>
66
67     <indexterm><primary>RTS options</primary><secondary>from the environment</secondary></indexterm>
68     <indexterm><primary>environment variable</primary><secondary>for
69     setting RTS options</secondary></indexterm>
70
71     <para>RTS options are also taken from the environment variable
72     <envar>GHCRTS</envar><indexterm><primary><envar>GHCRTS</envar></primary>
73       </indexterm>.  For example, to set the maximum heap size
74     to 128M for all GHC-compiled programs (using an
75     <literal>sh</literal>-like shell):</para>
76
77 <screen>
78    GHCRTS='-M128m'
79    export GHCRTS
80 </screen>
81
82     <para>RTS options taken from the <envar>GHCRTS</envar> environment
83     variable can be overridden by options given on the command
84     line.</para>
85
86   </sect2>
87
88   <sect2 id="rts-options-misc">
89     <title>Miscellaneous RTS options</title>
90
91     <variablelist>
92      <varlistentry>
93        <term><option>-V<replaceable>secs</replaceable></option>
94        <indexterm><primary><option>-V</option></primary><secondary>RTS
95        option</secondary></indexterm></term>
96        <listitem>
97          <para>Sets the interval that the RTS clock ticks at.  The
98          runtime uses a single timer signal to count ticks; this timer
99          signal is used to control the context switch timer (<xref
100          linkend="using-concurrent" />) and the heap profiling
101          timer <xref linkend="rts-options-heap-prof" />.  Also, the
102          time profiler uses the RTS timer signal directly to record
103          time profiling samples.</para>
104
105          <para>Normally, setting the <option>-V</option> option
106          directly is not necessary: the resolution of the RTS timer is
107          adjusted automatically if a short interval is requested with
108          the <option>-C</option> or <option>-i</option> options.
109          However, setting <option>-V</option> is required in order to
110          increase the resolution of the time profiler.</para>
111        </listitem>
112      </varlistentry>
113
114      <varlistentry>
115        <term><option>--install-signal-handlers=<replaceable>yes|no</replaceable></option>
116        <indexterm><primary><option>--install-signal-handlers</option></primary><secondary>RTS
117        option</secondary></indexterm></term>
118        <listitem>
119          <para>If yes (the default), the RTS installs signal handlers to catch
120          things like ctrl-C. This option is primarily useful for when
121          you are using the Haskell code as a DLL, and want to set your
122          own signal handlers.</para>
123        </listitem>
124      </varlistentry>
125     </variablelist>
126   </sect2>
127
128   <sect2 id="rts-options-gc">
129     <title>RTS options to control the garbage collector</title>
130
131     <indexterm><primary>garbage collector</primary><secondary>options</secondary></indexterm>
132     <indexterm><primary>RTS options</primary><secondary>garbage collection</secondary></indexterm>
133
134     <para>There are several options to give you precise control over
135     garbage collection.  Hopefully, you won't need any of these in
136     normal operation, but there are several things that can be tweaked
137     for maximum performance.</para>
138
139     <variablelist>
140
141       <varlistentry>
142         <term>
143           <option>-A</option><replaceable>size</replaceable>
144           <indexterm><primary><option>-A</option></primary><secondary>RTS option</secondary></indexterm>
145           <indexterm><primary>allocation area, size</primary></indexterm>
146         </term>
147         <listitem>
148           <para>&lsqb;Default: 256k&rsqb; Set the allocation area size
149           used by the garbage collector.  The allocation area
150           (actually generation 0 step 0) is fixed and is never resized
151           (unless you use <option>-H</option>, below).</para>
152
153           <para>Increasing the allocation area size may or may not
154           give better performance (a bigger allocation area means
155           worse cache behaviour but fewer garbage collections and less
156           promotion).</para>
157
158           <para>With only 1 generation (<option>-G1</option>) the
159           <option>-A</option> option specifies the minimum allocation
160           area, since the actual size of the allocation area will be
161           resized according to the amount of data in the heap (see
162           <option>-F</option>, below).</para>
163         </listitem>
164       </varlistentry>
165
166       <varlistentry>
167         <term>
168           <option>-c</option>
169           <indexterm><primary><option>-c</option></primary><secondary>RTS option</secondary></indexterm>
170           <indexterm><primary>garbage collection</primary><secondary>compacting</secondary></indexterm>
171           <indexterm><primary>compacting garbage collection</primary></indexterm>
172         </term>
173         <listitem>
174           <para>Use a compacting algorithm for collecting the oldest
175           generation.  By default, the oldest generation is collected
176           using a copying algorithm; this option causes it to be
177           compacted in-place instead.  The compaction algorithm is
178           slower than the copying algorithm, but the savings in memory
179           use can be considerable.</para>
180
181           <para>For a given heap size (using the <option>-H</option>
182           option), compaction can in fact reduce the GC cost by
183           allowing fewer GCs to be performed.  This is more likely
184           when the ratio of live data to heap size is high, say
185           &gt;30&percnt;.</para>
186
187           <para>NOTE: compaction doesn't currently work when a single
188           generation is requested using the <option>-G1</option>
189           option.</para>
190         </listitem>
191       </varlistentry>
192
193       <varlistentry>
194         <term><option>-c</option><replaceable>n</replaceable></term>
195
196         <listitem>
197           <para>&lsqb;Default: 30&rsqb; Automatically enable
198           compacting collection when the live data exceeds
199           <replaceable>n</replaceable>&percnt; of the maximum heap size
200           (see the <option>-M</option> option).  Note that the maximum
201           heap size is unlimited by default, so this option has no
202           effect unless the maximum heap size is set with
203           <option>-M</option><replaceable>size</replaceable>. </para>
204         </listitem>
205       </varlistentry>
206
207       <varlistentry>
208         <term>
209           <option>-F</option><replaceable>factor</replaceable>
210           <indexterm><primary><option>-F</option></primary><secondary>RTS option</secondary></indexterm>
211           <indexterm><primary>heap size, factor</primary></indexterm>
212         </term>
213         <listitem>
214
215           <para>&lsqb;Default: 2&rsqb; This option controls the amount
216           of memory reserved for the older generations (and in the
217           case of a two space collector the size of the allocation
218           area) as a factor of the amount of live data.  For example,
219           if there was 2M of live data in the oldest generation when
220           we last collected it, then by default we'll wait until it
221           grows to 4M before collecting it again.</para>
222
223           <para>The default seems to work well here.  If you have
224           plenty of memory, it is usually better to use
225           <option>-H</option><replaceable>size</replaceable> than to
226           increase
227           <option>-F</option><replaceable>factor</replaceable>.</para>
228
229           <para>The <option>-F</option> setting will be automatically
230           reduced by the garbage collector when the maximum heap size
231           (the <option>-M</option><replaceable>size</replaceable>
232           setting) is approaching.</para>
233         </listitem>
234       </varlistentry>
235
236       <varlistentry>
237         <term>
238           <option>-G</option><replaceable>generations</replaceable>
239           <indexterm><primary><option>-G</option></primary><secondary>RTS option</secondary></indexterm>
240           <indexterm><primary>generations, number of</primary></indexterm>
241         </term>
242         <listitem>
243           <para>&lsqb;Default: 2&rsqb; Set the number of generations
244           used by the garbage collector.  The default of 2 seems to be
245           good, but the garbage collector can support any number of
246           generations.  Anything larger than about 4 is probably not a
247           good idea unless your program runs for a
248           <emphasis>long</emphasis> time, because the oldest
249           generation will hardly ever get collected.</para>
250
251           <para>Specifying 1 generation with <option>+RTS -G1</option>
252           gives you a simple 2-space collector, as you would expect.
253           In a 2-space collector, the <option>-A</option> option (see
254           above) specifies the <emphasis>minimum</emphasis> allocation
255           area size, since the allocation area will grow with the
256           amount of live data in the heap.  In a multi-generational
257           collector the allocation area is a fixed size (unless you
258           use the <option>-H</option> option, see below).</para>
259         </listitem>
260       </varlistentry>
261
262       <varlistentry>
263         <term>
264           <option>-H</option><replaceable>size</replaceable>
265           <indexterm><primary><option>-H</option></primary><secondary>RTS option</secondary></indexterm>
266           <indexterm><primary>heap size, suggested</primary></indexterm>
267         </term>
268         <listitem>
269           <para>&lsqb;Default: 0&rsqb; This option provides a
270           &ldquo;suggested heap size&rdquo; for the garbage collector.  The
271           garbage collector will use about this much memory until the
272           program residency grows and the heap size needs to be
273           expanded to retain reasonable performance.</para>
274
275           <para>By default, the heap will start small, and grow and
276           shrink as necessary.  This can be bad for performance, so if
277           you have plenty of memory it's worthwhile supplying a big
278           <option>-H</option><replaceable>size</replaceable>.  For
279           improving GC performance, using
280           <option>-H</option><replaceable>size</replaceable> is
281           usually a better bet than
282           <option>-A</option><replaceable>size</replaceable>.</para>
283         </listitem>
284       </varlistentry>
285
286       <varlistentry>
287         <term>
288           <option>-I</option><replaceable>seconds</replaceable>
289           <indexterm><primary><option>-I</option></primary>
290             <secondary>RTS option</secondary>
291           </indexterm>
292           <indexterm><primary>idle GC</primary>
293           </indexterm>
294           </term>
295         <listitem>
296           <para>(default: 0.3) In the threaded and SMP versions of the RTS (see
297             <option>-threaded</option>, <xref linkend="options-linker" />), a
298             major GC is automatically performed if the runtime has been idle
299             (no Haskell computation has been running) for a period of time.
300             The amount of idle time which must pass before a GC is performed is
301             set by the <option>-I</option><replaceable>seconds</replaceable>
302             option.  Specifying <option>-I0</option> disables the idle GC.</para>
303
304           <para>For an interactive application, it is probably a good idea to
305             use the idle GC, because this will allow finalizers to run and
306             deadlocked threads to be detected in the idle time when no Haskell
307             computation is happening.  Also, it will mean that a GC is less
308             likely to happen when the application is busy, and so
309             responsiveness may be improved.   However, if the amount of live data in
310             the heap is particularly large, then the idle GC can cause a
311             significant delay, and too small an interval could adversely affect
312             interactive responsiveness.</para>
313
314           <para>This is an experimental feature, please let us know if it
315             causes problems and/or could benefit from further tuning.</para>
316         </listitem>
317       </varlistentry>
318
319       <varlistentry>
320         <term>
321          <option>-k</option><replaceable>size</replaceable>
322          <indexterm><primary><option>-k</option></primary><secondary>RTS option</secondary></indexterm>
323          <indexterm><primary>stack, minimum size</primary></indexterm>
324         </term>
325         <listitem>
326           <para>&lsqb;Default: 1k&rsqb; Set the initial stack size for
327           new threads.  Thread stacks (including the main thread's
328           stack) live on the heap, and grow as required.  The default
329           value is good for concurrent applications with lots of small
330           threads; if your program doesn't fit this model then
331           increasing this option may help performance.</para>
332
333           <para>The main thread is normally started with a slightly
334           larger heap to cut down on unnecessary stack growth while
335           the program is starting up.</para>
336         </listitem>
337       </varlistentry>
338
339       <varlistentry>
340         <term>
341           <option>-K</option><replaceable>size</replaceable>
342           <indexterm><primary><option>-K</option></primary><secondary>RTS option</secondary></indexterm>
343           <indexterm><primary>stack, maximum size</primary></indexterm>
344         </term>
345         <listitem>
346           <para>&lsqb;Default: 8M&rsqb; Set the maximum stack size for
347           an individual thread to <replaceable>size</replaceable>
348           bytes.  This option is there purely to stop the program
349           eating up all the available memory in the machine if it gets
350           into an infinite loop.</para>
351         </listitem>
352       </varlistentry>
353
354       <varlistentry>
355         <term>
356           <option>-m</option><replaceable>n</replaceable>
357           <indexterm><primary><option>-m</option></primary><secondary>RTS option</secondary></indexterm>
358           <indexterm><primary>heap, minimum free</primary></indexterm>
359         </term>
360         <listitem>
361           <para>Minimum &percnt; <replaceable>n</replaceable> of heap
362           which must be available for allocation.  The default is
363           3&percnt;.</para>
364         </listitem>
365       </varlistentry>
366
367       <varlistentry>
368         <term>
369           <option>-M</option><replaceable>size</replaceable>
370           <indexterm><primary><option>-M</option></primary><secondary>RTS option</secondary></indexterm>
371           <indexterm><primary>heap size, maximum</primary></indexterm>
372         </term>
373         <listitem>
374           <para>&lsqb;Default: unlimited&rsqb; Set the maximum heap size to
375           <replaceable>size</replaceable> bytes.  The heap normally
376           grows and shrinks according to the memory requirements of
377           the program.  The only reason for having this option is to
378           stop the heap growing without bound and filling up all the
379           available swap space, which at the least will result in the
380           program being summarily killed by the operating
381           system.</para>
382
383           <para>The maximum heap size also affects other garbage
384           collection parameters: when the amount of live data in the
385           heap exceeds a certain fraction of the maximum heap size,
386           compacting collection will be automatically enabled for the
387           oldest generation, and the <option>-F</option> parameter
388           will be reduced in order to avoid exceeding the maximum heap
389           size.</para>
390         </listitem>
391       </varlistentry>
392
393       <varlistentry>
394         <term>
395           <option>-s</option><replaceable>file</replaceable>
396           <indexterm><primary><option>-s</option></primary><secondary>RTS option</secondary></indexterm>
397         </term>
398         <term>
399           <option>-S</option><replaceable>file</replaceable>
400           <indexterm><primary><option>-S</option></primary><secondary>RTS option</secondary></indexterm>
401         </term>
402         <listitem>
403           <para>Write modest (<option>-s</option>) or verbose
404           (<option>-S</option>) garbage-collector statistics into file
405           <replaceable>file</replaceable>. The default
406           <replaceable>file</replaceable> is
407           <filename><replaceable>program</replaceable>.stat</filename>. The
408           <replaceable>file</replaceable> <constant>stderr</constant>
409           is treated specially, with the output really being sent to
410           <constant>stderr</constant>.</para>
411
412           <para>This option is useful for watching how the storage
413           manager adjusts the heap size based on the current amount of
414           live data.</para>
415         </listitem>
416       </varlistentry>
417
418       <varlistentry>
419         <term>
420           <option>-t<replaceable>file</replaceable></option>
421           <indexterm><primary><option>-t</option></primary><secondary>RTS option</secondary></indexterm>
422         </term>
423         <listitem>
424           <para>Write a one-line GC stats summary after running the
425           program.  This output is in the same format as that produced
426           by the <option>-Rghc-timing</option> option.</para>
427
428           <para>As with <option>-s</option>, the default
429           <replaceable>file</replaceable> is
430           <filename><replaceable>program</replaceable>.stat</filename>. The
431           <replaceable>file</replaceable> <constant>stderr</constant>
432           is treated specially, with the output really being sent to
433           <constant>stderr</constant>.</para>
434         </listitem>
435       </varlistentry>
436     </variablelist>
437
438   </sect2>
439
440   <sect2>
441     <title>RTS options for profiling and parallelism</title>
442
443     <para>The RTS options related to profiling are described in <xref
444     linkend="rts-options-heap-prof"/>, those for concurrency in
445       <xref linkend="using-concurrent" />, and those for parallelism in
446       <xref linkend="parallel-options"/>.</para>
447   </sect2>
448
449   <sect2 id="rts-options-debugging">
450     <title>RTS options for hackers, debuggers, and over-interested
451     souls</title>
452
453     <indexterm><primary>RTS options, hacking/debugging</primary></indexterm>
454
455     <para>These RTS options might be used (a)&nbsp;to avoid a GHC bug,
456     (b)&nbsp;to see &ldquo;what's really happening&rdquo;, or
457     (c)&nbsp;because you feel like it.  Not recommended for everyday
458     use!</para>
459
460     <variablelist>
461
462       <varlistentry>
463         <term>
464           <option>-B</option>
465           <indexterm><primary><option>-B</option></primary><secondary>RTS option</secondary></indexterm>
466         </term>
467         <listitem>
468           <para>Sound the bell at the start of each (major) garbage
469           collection.</para>
470
471           <para>Oddly enough, people really do use this option!  Our
472           pal in Durham (England), Paul Callaghan, writes: &ldquo;Some
473           people here use it for a variety of
474           purposes&mdash;honestly!&mdash;e.g., confirmation that the
475           code/machine is doing something, infinite loop detection,
476           gauging cost of recently added code. Certain people can even
477           tell what stage &lsqb;the program&rsqb; is in by the beep
478           pattern. But the major use is for annoying others in the
479           same office&hellip;&rdquo;</para>
480         </listitem>
481       </varlistentry>
482
483       <varlistentry>
484         <term>
485           <option>-D</option><replaceable>num</replaceable>
486           <indexterm><primary>-D</primary><secondary>RTS option</secondary></indexterm>
487         </term>
488         <listitem>
489           <para>An RTS debugging flag; varying quantities of output
490           depending on which bits are set in
491           <replaceable>num</replaceable>.  Only works if the RTS was
492           compiled with the <option>DEBUG</option> option.</para>
493         </listitem>
494       </varlistentry>
495
496       <varlistentry>
497         <term>
498           <option>-r</option><replaceable>file</replaceable>
499           <indexterm><primary><option>-r</option></primary><secondary>RTS option</secondary></indexterm>
500           <indexterm><primary>ticky ticky profiling</primary></indexterm>
501           <indexterm><primary>profiling</primary><secondary>ticky ticky</secondary></indexterm>
502         </term>
503         <listitem>
504           <para>Produce &ldquo;ticky-ticky&rdquo; statistics at the
505           end of the program run.  The <replaceable>file</replaceable>
506           business works just like on the <option>-S</option> RTS
507           option (above).</para>
508
509           <para>&ldquo;Ticky-ticky&rdquo; statistics are counts of
510           various program actions (updates, enters, etc.)  The program
511           must have been compiled using
512           <option>-ticky</option><indexterm><primary><option>-ticky</option></primary></indexterm>
513           (a.k.a. &ldquo;ticky-ticky profiling&rdquo;), and, for it to
514           be really useful, linked with suitable system libraries.
515           Not a trivial undertaking: consult the installation guide on
516           how to set things up for easy &ldquo;ticky-ticky&rdquo;
517           profiling.  For more information, see <xref
518           linkend="ticky-ticky"/>.</para>
519         </listitem>
520       </varlistentry>
521
522       <varlistentry>
523         <term>
524           <option>-xc</option>
525           <indexterm><primary><option>-xc</option></primary><secondary>RTS option</secondary></indexterm>
526         </term>
527         <listitem>
528           <para>(Only available when the program is compiled for
529           profiling.)  When an exception is raised in the program,
530           this option causes the current cost-centre-stack to be
531           dumped to <literal>stderr</literal>.</para>
532
533           <para>This can be particularly useful for debugging: if your
534           program is complaining about a <literal>head []</literal>
535           error and you haven't got a clue which bit of code is
536           causing it, compiling with <literal>-prof
537           -auto-all</literal> and running with <literal>+RTS -xc
538           -RTS</literal> will tell you exactly the call stack at the
539           point the error was raised.</para>
540
541           <para>The output contains one line for each exception raised
542           in the program (the program might raise and catch several
543           exceptions during its execution), where each line is of the
544           form:</para>
545
546 <screen>
547 &lt; cc<subscript>1</subscript>, ..., cc<subscript>n</subscript> &gt;
548 </screen>
549           <para>each <literal>cc</literal><subscript>i</subscript> is
550           a cost centre in the program (see <xref
551           linkend="cost-centres"/>), and the sequence represents the
552           &ldquo;call stack&rdquo; at the point the exception was
553           raised.  The leftmost item is the innermost function in the
554           call stack, and the rightmost item is the outermost
555           function.</para>
556
557         </listitem>
558       </varlistentry>
559
560       <varlistentry>
561         <term>
562           <option>-Z</option>
563           <indexterm><primary><option>-Z</option></primary><secondary>RTS option</secondary></indexterm>
564         </term>
565         <listitem>
566           <para>Turn <emphasis>off</emphasis> &ldquo;update-frame
567           squeezing&rdquo; at garbage-collection time.  (There's no
568           particularly good reason to turn it off, except to ensure
569           the accuracy of certain data collected regarding thunk entry
570           counts.)</para>
571         </listitem>
572       </varlistentry>
573     </variablelist>
574
575   </sect2>
576
577   <sect2 id="rts-hooks">
578     <title>&ldquo;Hooks&rdquo; to change RTS behaviour</title>
579
580     <indexterm><primary>hooks</primary><secondary>RTS</secondary></indexterm>
581     <indexterm><primary>RTS hooks</primary></indexterm>
582     <indexterm><primary>RTS behaviour, changing</primary></indexterm>
583
584     <para>GHC lets you exercise rudimentary control over the RTS
585     settings for any given program, by compiling in a
586     &ldquo;hook&rdquo; that is called by the run-time system.  The RTS
587     contains stub definitions for all these hooks, but by writing your
588     own version and linking it on the GHC command line, you can
589     override the defaults.</para>
590
591     <para>Owing to the vagaries of DLL linking, these hooks don't work
592     under Windows when the program is built dynamically.</para>
593
594     <para>The hook <literal>ghc_rts_opts</literal><indexterm><primary><literal>ghc_rts_opts</literal></primary>
595       </indexterm>lets you set RTS
596     options permanently for a given program.  A common use for this is
597     to give your program a default heap and/or stack size that is
598     greater than the default.  For example, to set <literal>-H128m
599     -K1m</literal>, place the following definition in a C source
600     file:</para>
601
602 <programlisting>
603 char *ghc_rts_opts = "-H128m -K1m";
604 </programlisting>
605
606     <para>Compile the C file, and include the object file on the
607     command line when you link your Haskell program.</para>
608
609     <para>These flags are interpreted first, before any RTS flags from
610     the <literal>GHCRTS</literal> environment variable and any flags
611     on the command line.</para>
612
613     <para>You can also change the messages printed when the runtime
614     system &ldquo;blows up,&rdquo; e.g., on stack overflow.  The hooks
615     for these are as follows:</para>
616
617     <variablelist>
618
619       <varlistentry>
620         <term>
621           <function>void OutOfHeapHook (unsigned long, unsigned long)</function>
622           <indexterm><primary><function>OutOfHeapHook</function></primary></indexterm>
623         </term>
624         <listitem>
625           <para>The heap-overflow message.</para>
626         </listitem>
627       </varlistentry>
628
629       <varlistentry>
630         <term>
631           <function>void StackOverflowHook (long int)</function>
632           <indexterm><primary><function>StackOverflowHook</function></primary></indexterm>
633         </term>
634         <listitem>
635           <para>The stack-overflow message.</para>
636         </listitem>
637       </varlistentry>
638
639       <varlistentry>
640         <term>
641           <function>void MallocFailHook (long int)</function>
642           <indexterm><primary><function>MallocFailHook</function></primary></indexterm>
643         </term>
644         <listitem>
645           <para>The message printed if <function>malloc</function>
646           fails.</para>
647         </listitem>
648       </varlistentry>
649     </variablelist>
650
651     <para>For examples of the use of these hooks, see GHC's own
652     versions in the file
653     <filename>ghc/compiler/parser/hschooks.c</filename> in a GHC
654     source tree.</para>
655   </sect2>
656 </sect1>
657
658 <!-- Emacs stuff:
659      ;;; Local Variables: ***
660      ;;; mode: xml ***
661      ;;; sgml-parent-document: ("users_guide.xml" "book" "chapter" "sect1") ***
662      ;;; End: ***
663  -->