summaryrefslogtreecommitdiff
path: root/testsuite/tests/regression/pr9326/gc_set.ml
blob: e672e23c9d87274738af2a0257b6bd36e050002b (plain)
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
(* TEST *)

open Gc

let min_heap_sz = 524288 (* 512k *)
let space_overhead = 70
let stack_limit = 4194304 (* 4M *)
let custom_major_ratio = 40
let custom_minor_ratio = 99
let custom_minor_max_size = 4096

let _ =
  let g1 = Gc.get() in
  (* Do not use { g1 with ... }, so that the code will break if more fields
     are added to the Gc.control record type *)
  Gc.set { minor_heap_size = min_heap_sz;
           major_heap_increment = g1.major_heap_increment;
           space_overhead = space_overhead;
           verbose = g1.verbose;
           max_overhead = g1.max_overhead;
           stack_limit = stack_limit;
           allocation_policy = g1.allocation_policy;
           window_size = g1.window_size;
           custom_major_ratio = custom_major_ratio;
           custom_minor_ratio = custom_minor_ratio;
           custom_minor_max_size = custom_minor_max_size };
  let g2 = Gc.get() in
  assert (g2.minor_heap_size = min_heap_sz);
  assert (g2.space_overhead = space_overhead);
  assert (g2.verbose = g1.verbose);
  assert (g2.max_overhead = g1.max_overhead);
  assert (g2.stack_limit = stack_limit);
  assert (g2.allocation_policy = g1.allocation_policy);
  assert (g2.window_size = g1.window_size);
  assert (g2.custom_major_ratio = custom_major_ratio);
  assert (g2.custom_minor_ratio = custom_minor_ratio);
  assert (g2.custom_minor_max_size = custom_minor_max_size)