summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--byterun/gc_ctrl.c4
-rw-r--r--byterun/gc_ctrl.h1
-rw-r--r--byterun/major_gc.c1
-rw-r--r--byterun/memory.c1
-rw-r--r--stdlib/gc.ml11
-rw-r--r--stdlib/gc.mli18
6 files changed, 29 insertions, 7 deletions
diff --git a/byterun/gc_ctrl.c b/byterun/gc_ctrl.c
index 03aa52522..7d6249057 100644
--- a/byterun/gc_ctrl.c
+++ b/byterun/gc_ctrl.c
@@ -36,6 +36,7 @@ double stat_minor_words = 0.0,
long stat_minor_collections = 0,
stat_major_collections = 0,
stat_heap_size = 0, /* bytes */
+ stat_top_heap_size = 0, /* bytes */
stat_compactions = 0;
extern asize_t major_heap_increment; /* bytes; see major_gc.c */
@@ -210,7 +211,7 @@ static value heap_stats (int returnstats)
long heap_words = Wsize_bsize (stat_heap_size);
long cpct = stat_compactions;
- res = alloc_tuple (14);
+ res = alloc_tuple (15);
Store_field (res, 0, copy_double (minwords));
Store_field (res, 1, copy_double (prowords));
Store_field (res, 2, copy_double (majwords));
@@ -225,6 +226,7 @@ static value heap_stats (int returnstats)
Store_field (res, 11, Val_long (largest_free));
Store_field (res, 12, Val_long (fragments));
Store_field (res, 13, Val_long (cpct));
+ Store_field (res, 14, Val_long (Wsize_bsize (stat_top_heap_size)));
CAMLreturn (res);
}else{
CAMLreturn (Val_unit);
diff --git a/byterun/gc_ctrl.h b/byterun/gc_ctrl.h
index 4b1a9c735..9140170ad 100644
--- a/byterun/gc_ctrl.h
+++ b/byterun/gc_ctrl.h
@@ -27,6 +27,7 @@ extern long
stat_minor_collections,
stat_major_collections,
stat_heap_size,
+ stat_top_heap_size,
stat_compactions;
void init_gc (unsigned long, unsigned long, unsigned long,
diff --git a/byterun/major_gc.c b/byterun/major_gc.c
index 8cb65eb32..c94e86cc9 100644
--- a/byterun/major_gc.c
+++ b/byterun/major_gc.c
@@ -367,6 +367,7 @@ void init_major_heap (asize_t heap_size)
page_table_entry *page_table_block;
stat_heap_size = round_heap_chunk_size (heap_size);
+ stat_top_heap_size = stat_heap_size;
Assert (stat_heap_size % Page_size == 0);
heap_start = aligned_malloc (stat_heap_size + sizeof (heap_chunk_head),
sizeof (heap_chunk_head), &block);
diff --git a/byterun/memory.c b/byterun/memory.c
index fc0fe57a7..88336d6b9 100644
--- a/byterun/memory.c
+++ b/byterun/memory.c
@@ -136,6 +136,7 @@ int add_to_heap (header_t *mem)
if (m + Chunk_size (m) > heap_end) heap_end = m + Chunk_size (m);
stat_heap_size += Chunk_size (m);
+ if (stat_heap_size > stat_top_heap_size) stat_top_heap_size = stat_heap_size;
return 0;
}
diff --git a/stdlib/gc.ml b/stdlib/gc.ml
index a62714569..c50dbaef4 100644
--- a/stdlib/gc.ml
+++ b/stdlib/gc.ml
@@ -27,7 +27,8 @@ type stat = {
free_blocks : int;
largest_free : int;
fragments : int;
- compactions : int
+ compactions : int;
+ top_heap_words : int;
};;
type control = {
@@ -36,7 +37,7 @@ type control = {
mutable space_overhead : int;
mutable verbose : int;
mutable max_overhead : int;
- mutable stack_limit : int
+ mutable stack_limit : int;
};;
external stat : unit -> stat = "gc_stat";;
@@ -59,6 +60,7 @@ let print_stat c =
fprintf c "major_collections: %d\n" st.major_collections;
fprintf c "heap_words: %d\n" st.heap_words;
fprintf c "heap_chunks: %d\n" st.heap_chunks;
+ fprintf c "top_heap_words: %d\n" st.top_heap_words;
fprintf c "live_words: %d\n" st.live_words;
fprintf c "live_blocks: %d\n" st.live_blocks;
fprintf c "free_words: %d\n" st.free_words;
@@ -76,9 +78,8 @@ let allocated_bytes () =
external finalise : ('a -> unit) -> 'a -> unit = "final_register";;
-type alarm_rec = {active : alarm; f : unit -> unit}
-and alarm = bool ref
-;;
+type alarm = bool ref;;
+type alarm_rec = {active : alarm; f : unit -> unit};;
let rec call_alarm arec =
if !(arec.active) then begin
diff --git a/stdlib/gc.mli b/stdlib/gc.mli
index 57c4e28c1..81b7be578 100644
--- a/stdlib/gc.mli
+++ b/stdlib/gc.mli
@@ -20,41 +20,57 @@ type stat =
(** Number of words allocated in the minor heap since
the program was started. This number is accurate in the
byte-code runtime, but only approximate in the native runtime. *)
+
promoted_words : float;
(** 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. *)
+
major_words : float;
(** Number of words allocated in the major heap, including
the promoted words, since the program was started. *)
+
minor_collections : int;
(** Number of minor collections since the program was started. *)
+
major_collections : int;
(** Number of major collection cycles, not counting
the current cycle, since the program was started. *)
+
heap_words : int;
(** Total size of the major heap, in words. *)
+
heap_chunks : int;
(** Number of times the major heap size was increased
since the program was started (including the initial allocation
of the heap). *)
+
live_words : int;
(** Number of words of live data in the major heap, including the header
words. *)
+
live_blocks : int;
(** Number of live blocks in the major heap. *)
+
free_words : int;
(** Number of words in the free list. *)
+
free_blocks : int;
(** Number of blocks in the free list. *)
+
largest_free : int;
(** Size (in words) of the largest block in the free list. *)
+
fragments : int;
(** Number of wasted words due to fragmentation. These are
1-words free blocks placed between two live blocks. They
are not available for allocation. *)
+
compactions : int;
- (** Number of heap compactions since the program was started. *)
+ (** Number of heap compactions since the program was started. *)
+
+ top_heap_words : int;
+ (** Maximum size reached by the major heap, in words. *)
}
(** The memory management counters are returned in a [stat] record.