1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="Start" href="index.html">
<link rel="previous" href="Stdlib.Fun.html">
<link rel="next" href="Stdlib.Genlex.html">
<link rel="Up" href="Stdlib.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of extensions" rel=Appendix href="index_extensions.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Index of module types" rel=Appendix href="index_module_types.html">
<link title="Arg" rel="Chapter" href="Arg.html">
<link title="Array" rel="Chapter" href="Array.html">
<link title="ArrayLabels" rel="Chapter" href="ArrayLabels.html">
<link title="Bigarray" rel="Chapter" href="Bigarray.html">
<link title="Bool" rel="Chapter" href="Bool.html">
<link title="Buffer" rel="Chapter" href="Buffer.html">
<link title="Bytes" rel="Chapter" href="Bytes.html">
<link title="BytesLabels" rel="Chapter" href="BytesLabels.html">
<link title="Callback" rel="Chapter" href="Callback.html">
<link title="CamlinternalFormat" rel="Chapter" href="CamlinternalFormat.html">
<link title="CamlinternalFormatBasics" rel="Chapter" href="CamlinternalFormatBasics.html">
<link title="CamlinternalLazy" rel="Chapter" href="CamlinternalLazy.html">
<link title="CamlinternalMod" rel="Chapter" href="CamlinternalMod.html">
<link title="CamlinternalOO" rel="Chapter" href="CamlinternalOO.html">
<link title="Char" rel="Chapter" href="Char.html">
<link title="Complex" rel="Chapter" href="Complex.html">
<link title="Condition" rel="Chapter" href="Condition.html">
<link title="Digest" rel="Chapter" href="Digest.html">
<link title="Dynlink" rel="Chapter" href="Dynlink.html">
<link title="Ephemeron" rel="Chapter" href="Ephemeron.html">
<link title="Event" rel="Chapter" href="Event.html">
<link title="Filename" rel="Chapter" href="Filename.html">
<link title="Float" rel="Chapter" href="Float.html">
<link title="Format" rel="Chapter" href="Format.html">
<link title="Fun" rel="Chapter" href="Fun.html">
<link title="Gc" rel="Chapter" href="Gc.html">
<link title="Genlex" rel="Chapter" href="Genlex.html">
<link title="Hashtbl" rel="Chapter" href="Hashtbl.html">
<link title="Int" rel="Chapter" href="Int.html">
<link title="Int32" rel="Chapter" href="Int32.html">
<link title="Int64" rel="Chapter" href="Int64.html">
<link title="Lazy" rel="Chapter" href="Lazy.html">
<link title="Lexing" rel="Chapter" href="Lexing.html">
<link title="List" rel="Chapter" href="List.html">
<link title="ListLabels" rel="Chapter" href="ListLabels.html">
<link title="Map" rel="Chapter" href="Map.html">
<link title="Marshal" rel="Chapter" href="Marshal.html">
<link title="MoreLabels" rel="Chapter" href="MoreLabels.html">
<link title="Mutex" rel="Chapter" href="Mutex.html">
<link title="Nativeint" rel="Chapter" href="Nativeint.html">
<link title="Obj" rel="Chapter" href="Obj.html">
<link title="Ocaml_operators" rel="Chapter" href="Ocaml_operators.html">
<link title="Oo" rel="Chapter" href="Oo.html">
<link title="Option" rel="Chapter" href="Option.html">
<link title="Parsing" rel="Chapter" href="Parsing.html">
<link title="Printexc" rel="Chapter" href="Printexc.html">
<link title="Printf" rel="Chapter" href="Printf.html">
<link title="Queue" rel="Chapter" href="Queue.html">
<link title="Random" rel="Chapter" href="Random.html">
<link title="Result" rel="Chapter" href="Result.html">
<link title="Scanf" rel="Chapter" href="Scanf.html">
<link title="Seq" rel="Chapter" href="Seq.html">
<link title="Set" rel="Chapter" href="Set.html">
<link title="Spacetime" rel="Chapter" href="Spacetime.html">
<link title="Stack" rel="Chapter" href="Stack.html">
<link title="StdLabels" rel="Chapter" href="StdLabels.html">
<link title="Stdlib" rel="Chapter" href="Stdlib.html">
<link title="Str" rel="Chapter" href="Str.html">
<link title="Stream" rel="Chapter" href="Stream.html">
<link title="String" rel="Chapter" href="String.html">
<link title="StringLabels" rel="Chapter" href="StringLabels.html">
<link title="Sys" rel="Chapter" href="Sys.html">
<link title="Thread" rel="Chapter" href="Thread.html">
<link title="ThreadUnix" rel="Chapter" href="ThreadUnix.html">
<link title="Uchar" rel="Chapter" href="Uchar.html">
<link title="Unit" rel="Chapter" href="Unit.html">
<link title="Unix" rel="Chapter" href="Unix.html">
<link title="UnixLabels" rel="Chapter" href="UnixLabels.html">
<link title="Weak" rel="Chapter" href="Weak.html"><title>Stdlib.Gc</title>
</head>
<body>
<div class="navbar"><a class="pre" href="Stdlib.Fun.html" title="Stdlib.Fun">Previous</a>
<a class="up" href="Stdlib.html" title="Stdlib">Up</a>
<a class="post" href="Stdlib.Genlex.html" title="Stdlib.Genlex">Next</a>
</div>
<h1>Module <a href="type_Stdlib.Gc.html">Stdlib.Gc</a></h1>
<pre><span id="MODULEGc"><span class="keyword">module</span> Gc</span>: <code class="type"><a href="Gc.html">Gc</a></code></pre><hr width="100%">
<pre><code><span id="TYPEstat"><span class="keyword">type</span> <code class="type"></code>stat</span> = {</code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstat.minor_words">minor_words</span> : <code class="type">float</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Number of words allocated in the minor heap since
the program was started.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstat.promoted_words">promoted_words</span> : <code class="type">float</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Number of words allocated in the minor heap that
survived a minor collection and were moved to the major heap
since the program was started.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstat.major_words">major_words</span> : <code class="type">float</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Number of words allocated in the major heap, including
the promoted words, since the program was started.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstat.minor_collections">minor_collections</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Number of minor collections since the program was started.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstat.major_collections">major_collections</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Number of major collection cycles completed since the program
was started.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstat.heap_words">heap_words</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Total size of the major heap, in words.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstat.heap_chunks">heap_chunks</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Number of contiguous pieces of memory that make up the major heap.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstat.live_words">live_words</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Number of words of live data in the major heap, including the header
words.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstat.live_blocks">live_blocks</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Number of live blocks in the major heap.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstat.free_words">free_words</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Number of words in the free list.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstat.free_blocks">free_blocks</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Number of blocks in the free list.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstat.largest_free">largest_free</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Size (in words) of the largest block in the free list.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstat.fragments">fragments</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Number of wasted words due to fragmentation. These are
1-words free blocks placed between two live blocks. They
are not available for allocation.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstat.compactions">compactions</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Number of heap compactions since the program was started.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstat.top_heap_words">top_heap_words</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Maximum size reached by the major heap, in words.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTstat.stack_size">stack_size</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Current size of the stack, in words.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 3.12.0</li>
</ul>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr></table>
<code>}</code>
<div class="info ">
<div class="info-desc">
<p>The memory management counters are returned in a <code class="code">stat</code> record.</p>
<p>The total amount of memory allocated by the program since it was started
is (in words) <code class="code">minor_words + major_words - promoted_words</code>. Multiply by
the word size (4 on a 32-bit machine, 8 on a 64-bit machine) to get
the number of bytes.</p>
</div>
</div>
<pre><code><span id="TYPEcontrol"><span class="keyword">type</span> <code class="type"></code>control</span> = {</code></pre><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTcontrol.minor_heap_size">minor_heap_size</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>The size (in words) of the minor heap. Changing
this parameter will trigger a minor collection. Default: 256k.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTcontrol.major_heap_increment">major_heap_increment</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>How much to add to the major heap when increasing it. If this
number is less than or equal to 1000, it is a percentage of
the current heap size (i.e. setting it to 100 will double the heap
size at each increase). If it is more than 1000, it is a fixed
number of words that will be added to the heap. Default: 15.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTcontrol.space_overhead">space_overhead</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>The major GC speed is computed from this parameter.
This is the memory that will be "wasted" because the GC does not
immediately collect unreachable blocks. It is expressed as a
percentage of the memory used for live data.
The GC will work more (use more CPU time and collect
blocks more eagerly) if <code class="code">space_overhead</code> is smaller.
Default: 80.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTcontrol.verbose">verbose</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>This value controls the GC messages on standard error output.
It is a sum of some of the following flags, to print messages
on the corresponding events:</p>
<ul>
<li><code class="code">0x001</code> Start of major GC cycle.</li>
<li><code class="code">0x002</code> Minor collection and major GC slice.</li>
<li><code class="code">0x004</code> Growing and shrinking of the heap.</li>
<li><code class="code">0x008</code> Resizing of stacks and memory manager tables.</li>
<li><code class="code">0x010</code> Heap compaction.</li>
<li><code class="code">0x020</code> Change of GC parameters.</li>
<li><code class="code">0x040</code> Computation of major GC slice size.</li>
<li><code class="code">0x080</code> Calling of finalisation functions.</li>
<li><code class="code">0x100</code> Bytecode executable and shared library search at start-up.</li>
<li><code class="code">0x200</code> Computation of compaction-triggering condition.</li>
<li><code class="code">0x400</code> Output GC statistics at program exit.
Default: 0.</li>
</ul>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTcontrol.max_overhead">max_overhead</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Heap compaction is triggered when the estimated amount
of "wasted" memory is more than <code class="code">max_overhead</code> percent of the
amount of live data. If <code class="code">max_overhead</code> is set to 0, heap
compaction is triggered at the end of each major GC cycle
(this setting is intended for testing purposes only).
If <code class="code">max_overhead >= 1000000</code>, compaction is never triggered.
If compaction is permanently disabled, it is strongly suggested
to set <code class="code">allocation_policy</code> to 2.
Default: 500.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTcontrol.stack_limit">stack_limit</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>The maximum size of the stack (in words). This is only
relevant to the byte-code runtime, as the native code runtime
uses the operating system's stack. Default: 1024k.</p>
</div>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span class="keyword">mutable </span><span id="TYPEELTcontrol.allocation_policy">allocation_policy</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>The policy used for allocating in the major heap.
Possible values are 0, 1 and 2.</p>
<ul>
<li>0 is the next-fit policy, which is usually fast but can
result in fragmentation, increasing memory consumption.</li>
</ul>
<ul>
<li>1 is the first-fit policy, which avoids fragmentation but
has corner cases (in certain realistic workloads) where it
is sensibly slower.</li>
</ul>
<ul>
<li>2 is the best-fit policy, which is fast and avoids
fragmentation. In our experiments it is faster and uses less
memory than both next-fit and first-fit.
(since OCaml 4.10)</li>
</ul>
<p>The current default is next-fit, as the best-fit policy is new
and not yet widely tested. We expect best-fit to become the
default in the future.</p>
<p>On one example that was known to be bad for next-fit and first-fit,
next-fit takes 28s using 855Mio of memory,
first-fit takes 47s using 566Mio of memory,
best-fit takes 27s using 545Mio of memory.</p>
<p>Note: When changing to a low-fragmentation policy, you may
need to augment the <code class="code">space_overhead</code> setting, for example
using <code class="code">100</code> instead of the default <code class="code">80</code> which is tuned for
next-fit. Indeed, the difference in fragmentation behavior
means that different policies will have different proportion
of "wasted space" for a given program. Less fragmentation
means a smaller heap so, for the same amount of wasted space,
a higher proportion of wasted space. This makes the GC work
harder, unless you relax it by increasing <code class="code">space_overhead</code>.</p>
<p>Note: changing the allocation policy at run-time forces
a heap compaction, which is a lengthy operation unless the
heap is small (e.g. at the start of the program).</p>
<p>Default: 0.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 3.11.0</li>
</ul>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTcontrol.window_size">window_size</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>The size of the window used by the major GC for smoothing
out variations in its workload. This is an integer between
1 and 50.
Default: 1.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.03.0</li>
</ul>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTcontrol.custom_major_ratio">custom_major_ratio</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Target ratio of floating garbage to major heap size for
out-of-heap memory held by custom values located in the major
heap. The GC speed is adjusted to try to use this much memory
for dead values that are not yet collected. Expressed as a
percentage of major heap size. The default value keeps the
out-of-heap floating garbage about the same size as the
in-heap overhead.
Note: this only applies to values allocated with
<code class="code">caml_alloc_custom_mem</code> (e.g. bigarrays).
Default: 44.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.08.0</li>
</ul>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTcontrol.custom_minor_ratio">custom_minor_ratio</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Bound on floating garbage for out-of-heap memory held by
custom values in the minor heap. A minor GC is triggered when
this much memory is held by custom values located in the minor
heap. Expressed as a percentage of minor heap size.
Note: this only applies to values allocated with
<code class="code">caml_alloc_custom_mem</code> (e.g. bigarrays).
Default: 100.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.08.0</li>
</ul>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code><span id="TYPEELTcontrol.custom_minor_max_size">custom_minor_max_size</span> : <code class="type">int</code>;</code></td>
<td class="typefieldcomment" align="left" valign="top" ><code>(*</code></td><td class="typefieldcomment" align="left" valign="top" ><div class="info ">
<div class="info-desc">
<p>Maximum amount of out-of-heap memory for each custom value
allocated in the minor heap. When a custom value is allocated
on the minor heap and holds more than this many bytes, only
this value is counted against <code class="code">custom_minor_ratio</code> and the
rest is directly counted against <code class="code">custom_major_ratio</code>.
Note: this only applies to values allocated with
<code class="code">caml_alloc_custom_mem</code> (e.g. bigarrays).
Default: 8192 bytes.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.08.0</li>
</ul>
</div>
</td><td class="typefieldcomment" align="left" valign="bottom" ><code>*)</code></td>
</tr></table>
<code>}</code>
<div class="info ">
<div class="info-desc">
<p>The GC parameters are given as a <code class="code">control</code> record. Note that
these parameters can also be initialised by setting the
OCAMLRUNPARAM environment variable. See the documentation of
<code class="code">ocamlrun</code>.</p>
</div>
</div>
<pre><span id="VALstat"><span class="keyword">val</span> stat</span> : <code class="type">unit -> <a href="Gc.html#TYPEstat">stat</a></code></pre><div class="info ">
<div class="info-desc">
<p>Return the current values of the memory management counters in a
<code class="code">stat</code> record. This function examines every heap block to get the
statistics.</p>
</div>
</div>
<pre><span id="VALquick_stat"><span class="keyword">val</span> quick_stat</span> : <code class="type">unit -> <a href="Gc.html#TYPEstat">stat</a></code></pre><div class="info ">
<div class="info-desc">
<p>Same as <code class="code">stat</code> except that <code class="code">live_words</code>, <code class="code">live_blocks</code>, <code class="code">free_words</code>,
<code class="code">free_blocks</code>, <code class="code">largest_free</code>, and <code class="code">fragments</code> are set to 0. This
function is much faster than <code class="code">stat</code> because it does not need to go
through the heap.</p>
</div>
</div>
<pre><span id="VALcounters"><span class="keyword">val</span> counters</span> : <code class="type">unit -> float * float * float</code></pre><div class="info ">
<div class="info-desc">
<p>Return <code class="code">(minor_words, promoted_words, major_words)</code>. This function
is as fast as <code class="code">quick_stat</code>.</p>
</div>
</div>
<pre><span id="VALminor_words"><span class="keyword">val</span> minor_words</span> : <code class="type">unit -> float</code></pre><div class="info ">
<div class="info-desc">
<p>Number of words allocated in the minor heap since the program was
started. This number is accurate in byte-code programs, but only an
approximation in programs compiled to native code.</p>
<p>In native code this function does not allocate.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.04</li>
</ul>
</div>
<pre><span id="VALget"><span class="keyword">val</span> get</span> : <code class="type">unit -> <a href="Gc.html#TYPEcontrol">control</a></code></pre><div class="info ">
<div class="info-desc">
<p>Return the current values of the GC parameters in a <code class="code">control</code> record.</p>
</div>
</div>
<pre><span id="VALset"><span class="keyword">val</span> set</span> : <code class="type"><a href="Gc.html#TYPEcontrol">control</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">set r</code> changes the GC parameters according to the <code class="code">control</code> record <code class="code">r</code>.
The normal usage is: <code class="code"><span class="constructor">Gc</span>.set { (<span class="constructor">Gc</span>.get()) <span class="keyword">with</span> <span class="constructor">Gc</span>.verbose = 0x00d }</code></p>
</div>
</div>
<pre><span id="VALminor"><span class="keyword">val</span> minor</span> : <code class="type">unit -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Trigger a minor collection.</p>
</div>
</div>
<pre><span id="VALmajor_slice"><span class="keyword">val</span> major_slice</span> : <code class="type">int -> int</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">major_slice n</code>
Do a minor collection and a slice of major collection. <code class="code">n</code> is the
size of the slice: the GC will do enough work to free (on average)
<code class="code">n</code> words of memory. If <code class="code">n</code> = 0, the GC will try to do enough work
to ensure that the next automatic slice has no work to do.
This function returns an unspecified integer (currently: 0).</p>
</div>
</div>
<pre><span id="VALmajor"><span class="keyword">val</span> major</span> : <code class="type">unit -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Do a minor collection and finish the current major collection cycle.</p>
</div>
</div>
<pre><span id="VALfull_major"><span class="keyword">val</span> full_major</span> : <code class="type">unit -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Do a minor collection, finish the current major collection cycle,
and perform a complete new cycle. This will collect all currently
unreachable blocks.</p>
</div>
</div>
<pre><span id="VALcompact"><span class="keyword">val</span> compact</span> : <code class="type">unit -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Perform a full major collection and compact the heap. Note that heap
compaction is a lengthy operation.</p>
</div>
</div>
<pre><span id="VALprint_stat"><span class="keyword">val</span> print_stat</span> : <code class="type"><a href="Stdlib.html#TYPEout_channel">out_channel</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Print the current values of the memory management counters (in
human-readable form) into the channel argument.</p>
</div>
</div>
<pre><span id="VALallocated_bytes"><span class="keyword">val</span> allocated_bytes</span> : <code class="type">unit -> float</code></pre><div class="info ">
<div class="info-desc">
<p>Return the total number of bytes allocated since the program was
started. It is returned as a <code class="code">float</code> to avoid overflow problems
with <code class="code">int</code> on 32-bit machines.</p>
</div>
</div>
<pre><span id="VALget_minor_free"><span class="keyword">val</span> get_minor_free</span> : <code class="type">unit -> int</code></pre><div class="info ">
<div class="info-desc">
<p>Return the current size of the free space inside the minor heap.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.03.0</li>
</ul>
</div>
<pre><span id="VALget_bucket"><span class="keyword">val</span> get_bucket</span> : <code class="type">int -> int</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">get_bucket n</code> returns the current size of the <code class="code">n</code>-th future bucket
of the GC smoothing system. The unit is one millionth of a full GC.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.03.0</li>
<li><b>Raises</b> <code>Invalid_argument</code> if <code class="code">n</code> is negative, return 0 if n is larger
than the smoothing window.</li>
</ul>
</div>
<pre><span id="VALget_credit"><span class="keyword">val</span> get_credit</span> : <code class="type">unit -> int</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">get_credit ()</code> returns the current size of the "work done in advance"
counter of the GC smoothing system. The unit is one millionth of a
full GC.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.03.0</li>
</ul>
</div>
<pre><span id="VALhuge_fallback_count"><span class="keyword">val</span> huge_fallback_count</span> : <code class="type">unit -> int</code></pre><div class="info ">
<div class="info-desc">
<p>Return the number of times we tried to map huge pages and had to fall
back to small pages. This is always 0 if <code class="code"><span class="constructor">OCAMLRUNPARAM</span></code> contains <code class="code"><span class="constructor">H</span>=1</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.03.0</li>
</ul>
</div>
<pre><span id="VALfinalise"><span class="keyword">val</span> finalise</span> : <code class="type">('a -> unit) -> 'a -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">finalise f v</code> registers <code class="code">f</code> as a finalisation function for <code class="code">v</code>.
<code class="code">v</code> must be heap-allocated. <code class="code">f</code> will be called with <code class="code">v</code> as
argument at some point between the first time <code class="code">v</code> becomes unreachable
(including through weak pointers) and the time <code class="code">v</code> is collected by
the GC. Several functions can
be registered for the same value, or even several instances of the
same function. Each instance will be called once (or never,
if the program terminates before <code class="code">v</code> becomes unreachable).</p>
<p>The GC will call the finalisation functions in the order of
deallocation. When several values become unreachable at the
same time (i.e. during the same GC cycle), the finalisation
functions will be called in the reverse order of the corresponding
calls to <code class="code">finalise</code>. If <code class="code">finalise</code> is called in the same order
as the values are allocated, that means each value is finalised
before the values it depends upon. Of course, this becomes
false if additional dependencies are introduced by assignments.</p>
<p>In the presence of multiple OCaml threads it should be assumed that
any particular finaliser may be executed in any of the threads.</p>
<p>Anything reachable from the closure of finalisation functions
is considered reachable, so the following code will not work
as expected:</p>
<ul>
<li><code class="code"> <span class="keyword">let</span> v = ... <span class="keyword">in</span> <span class="constructor">Gc</span>.finalise (<span class="keyword">fun</span> _ <span class="keywordsign">-></span> ...v...) v </code></li>
</ul>
<p>Instead you should make sure that <code class="code">v</code> is not in the closure of
the finalisation function by writing:</p>
<ul>
<li><code class="code"> <span class="keyword">let</span> f = <span class="keyword">fun</span> x <span class="keywordsign">-></span> ... <span class="keyword">let</span> v = ... <span class="keyword">in</span> <span class="constructor">Gc</span>.finalise f v </code></li>
</ul>
<p>The <code class="code">f</code> function can use all features of OCaml, including
assignments that make the value reachable again. It can also
loop forever (in this case, the other
finalisation functions will not be called during the execution of f,
unless it calls <code class="code">finalise_release</code>).
It can call <code class="code">finalise</code> on <code class="code">v</code> or other values to register other
functions or even itself. It can raise an exception; in this case
the exception will interrupt whatever the program was doing when
the function was called.</p>
<p><code class="code">finalise</code> will raise <code class="code"><span class="constructor">Invalid_argument</span></code> if <code class="code">v</code> is not
guaranteed to be heap-allocated. Some examples of values that are not
heap-allocated are integers, constant constructors, booleans,
the empty array, the empty list, the unit value. The exact list
of what is heap-allocated or not is implementation-dependent.
Some constant values can be heap-allocated but never deallocated
during the lifetime of the program, for example a list of integer
constants; this is also implementation-dependent.
Note that values of types <code class="code">float</code> are sometimes allocated and
sometimes not, so finalising them is unsafe, and <code class="code">finalise</code> will
also raise <code class="code"><span class="constructor">Invalid_argument</span></code> for them. Values of type <code class="code"><span class="keywordsign">'</span>a <span class="constructor">Lazy</span>.t</code>
(for any <code class="code"><span class="keywordsign">'</span>a</code>) are like <code class="code">float</code> in this respect, except that the
compiler sometimes optimizes them in a way that prevents <code class="code">finalise</code>
from detecting them. In this case, it will not raise
<code class="code"><span class="constructor">Invalid_argument</span></code>, but you should still avoid calling <code class="code">finalise</code>
on lazy values.</p>
<p>The results of calling <a href="String.html#VALmake"><code class="code"><span class="constructor">String</span>.make</code></a>, <a href="Bytes.html#VALmake"><code class="code"><span class="constructor">Bytes</span>.make</code></a>, <a href="Bytes.html#VALcreate"><code class="code"><span class="constructor">Bytes</span>.create</code></a>,
<a href="Array.html#VALmake"><code class="code"><span class="constructor">Array</span>.make</code></a>, and <a href="Stdlib.html#VALref"><code class="code">ref</code></a> are guaranteed to be
heap-allocated and non-constant except when the length argument is <code class="code">0</code>.</p>
</div>
</div>
<pre><span id="VALfinalise_last"><span class="keyword">val</span> finalise_last</span> : <code class="type">(unit -> unit) -> 'a -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>same as <a href="Gc.html#VALfinalise"><code class="code"><span class="constructor">Gc</span>.finalise</code></a> except the value is not given as argument. So
you can't use the given value for the computation of the
finalisation function. The benefit is that the function is called
after the value is unreachable for the last time instead of the
first time. So contrary to <a href="Gc.html#VALfinalise"><code class="code"><span class="constructor">Gc</span>.finalise</code></a> the value will never be
reachable again or used again. In particular every weak pointer
and ephemeron that contained this value as key or data is unset
before running the finalisation function. Moreover the finalisation
functions attached with <a href="Gc.html#VALfinalise"><code class="code"><span class="constructor">Gc</span>.finalise</code></a> are always called before the
finalisation functions attached with <a href="Gc.html#VALfinalise_last"><code class="code"><span class="constructor">Gc</span>.finalise_last</code></a>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.04</li>
</ul>
</div>
<pre><span id="VALfinalise_release"><span class="keyword">val</span> finalise_release</span> : <code class="type">unit -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>A finalisation function may call <code class="code">finalise_release</code> to tell the
GC that it can launch the next finalisation function without waiting
for the current one to return.</p>
</div>
</div>
<pre><span id="TYPEalarm"><span class="keyword">type</span> <code class="type"></code>alarm</span> </pre>
<div class="info ">
<div class="info-desc">
<p>An alarm is a piece of data that calls a user function at the end of
each major GC cycle. The following functions are provided to create
and delete alarms.</p>
</div>
</div>
<pre><span id="VALcreate_alarm"><span class="keyword">val</span> create_alarm</span> : <code class="type">(unit -> unit) -> <a href="Gc.html#TYPEalarm">alarm</a></code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">create_alarm f</code> will arrange for <code class="code">f</code> to be called at the end of each
major GC cycle, starting with the current cycle or the next one.
A value of type <code class="code">alarm</code> is returned that you can
use to call <code class="code">delete_alarm</code>.</p>
</div>
</div>
<pre><span id="VALdelete_alarm"><span class="keyword">val</span> delete_alarm</span> : <code class="type"><a href="Gc.html#TYPEalarm">alarm</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">delete_alarm a</code> will stop the calls to the function associated
to <code class="code">a</code>. Calling <code class="code">delete_alarm a</code> again has no effect.</p>
</div>
</div>
<pre><span id="VALeventlog_pause"><span class="keyword">val</span> eventlog_pause</span> : <code class="type">unit -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">eventlog_pause ()</code> will pause the collection of traces in the
runtime.
Traces are collected if the program is linked to the instrumented runtime
and started with the environment variable OCAML_EVENTLOG_ENABLED.
Events are flushed to disk after pausing, and no new events will be
recorded until <code class="code">eventlog_resume</code> is called.</p>
</div>
</div>
<pre><span id="VALeventlog_resume"><span class="keyword">val</span> eventlog_resume</span> : <code class="type">unit -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">eventlog_resume ()</code> will resume the collection of traces in the
runtime.
Traces are collected if the program is linked to the instrumented runtime
and started with the environment variable OCAML_EVENTLOG_ENABLED.
This call can be used after calling <code class="code">eventlog_pause</code>, or if the program
was started with OCAML_EVENTLOG_ENABLED=p. (which pauses the collection of
traces before the first event.)</p>
</div>
</div>
<pre><span id="MODULEMemprof"><span class="keyword">module</span> <a href="Gc.Memprof.html">Memprof</a></span>: <code class="code"><span class="keyword">sig</span></code> <a href="Gc.Memprof.html">..</a> <code class="code"><span class="keyword">end</span></code></pre><div class="info">
<p><code class="code"><span class="constructor">Memprof</span></code> is a sampling engine for allocated memory words.</p>
</div>
</body></html>
|