7 |
|
|
8 |
let add_memstat m f = memstat_functions := (m,f) :: !memstat_functions |
let add_memstat m f = memstat_functions := (m,f) :: !memstat_functions |
9 |
|
|
10 |
|
let _ = |
11 |
|
add_memstat "Gc" (fun level buf -> |
12 |
|
let stat = Gc.stat () in |
13 |
|
let ab = (stat.Gc.minor_words +. stat.Gc.major_words -. stat.Gc.promoted_words) |
14 |
|
*. float_of_int (Sys.word_size / 8) in |
15 |
|
Printf.bprintf buf "minor_words: %.0f\n" stat.Gc.minor_words; |
16 |
|
Printf.bprintf buf "promoted_words: %.0f\n" stat.Gc.promoted_words; |
17 |
|
Printf.bprintf buf "major_words: %.0f\n" stat.Gc.major_words; |
18 |
|
Printf.bprintf buf "minor_collections: %d\n" stat.Gc.minor_collections; |
19 |
|
Printf.bprintf buf "major_collections: %d\n" stat.Gc.major_collections; |
20 |
|
Printf.bprintf buf "heap_words: %d\n" stat.Gc.heap_words; |
21 |
|
Printf.bprintf buf "heap_chunks: %d\n" stat.Gc.heap_chunks; |
22 |
|
Printf.bprintf buf "live_words: %d\n" stat.Gc.live_words; |
23 |
|
Printf.bprintf buf "live_blocks: %d\n" stat.Gc.live_blocks; |
24 |
|
Printf.bprintf buf "free_words: %d\n" stat.Gc.free_words; |
25 |
|
Printf.bprintf buf "free_blocks: %d\n" stat.Gc.free_blocks; |
26 |
|
Printf.bprintf buf "largest_free: %d\n" stat.Gc.largest_free; |
27 |
|
Printf.bprintf buf "fragments: %d\n" stat.Gc.fragments; |
28 |
|
Printf.bprintf buf "compactions: %d\n" stat.Gc.compactions; |
29 |
|
Printf.bprintf buf "top_heap_words: %d\n" stat.Gc.top_heap_words; |
30 |
|
Printf.bprintf buf "allocated_bytes: %.0f\n" ab; |
31 |
|
) |
32 |
|
|
33 |
let print_memstats (level : int) buf use_html_mods = |
let print_memstats (level : int) buf use_html_mods = |
34 |
let level = if level < 0 then begin |
let level = if level < 0 then begin |
35 |
Gc.compact (); -level |
Gc.compact (); -level |