diff options
author | Damien Doligez <damien.doligez-inria.fr> | 2012-07-26 19:21:54 +0000 |
---|---|---|
committer | Damien Doligez <damien.doligez-inria.fr> | 2012-07-26 19:21:54 +0000 |
commit | 0c3a7de5079529bc99cbc9e68806f1a7021d94ef (patch) | |
tree | 3b973b6db6313c9bb2993b77c925c0dc8b457f7a /byterun/compact.c | |
parent | 229044d83a940d855fd9590d9aa76596f8c1a8b9 (diff) |
merge changes from 4.00 branching to 4.00.0 (part 1)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12784 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun/compact.c')
-rw-r--r-- | byterun/compact.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/byterun/compact.c b/byterun/compact.c index 17d574bb7..6c2164c31 100644 --- a/byterun/compact.c +++ b/byterun/compact.c @@ -397,7 +397,7 @@ uintnat caml_percent_max; /* used in gc_ctrl.c and memory.c */ void caml_compact_heap (void) { - uintnat target_size; + uintnat target_size, live; do_compaction (); /* Compaction may fail to shrink the heap to a reasonable size @@ -416,13 +416,15 @@ void caml_compact_heap (void) /* We compute: freewords = caml_fl_cur_size (exact) heapsize = caml_heap_size (exact) - usedwords = heap_size - freewords - target_size = usedwords * (1 + caml_percent_free / 100) + live = heap_size - freewords + target_size = live * (1 + caml_percent_free / 100) + = live / 100 * (100 + caml_percent_free) + We add 1 to live/100 to make sure it isn't 0. We recompact if target_size < heap_size / 2 */ - target_size = (caml_stat_heap_size - Bsize_wsize (caml_fl_cur_size)) - * (100 + caml_percent_free) / 100; + live = caml_stat_heap_size - Bsize_wsize (caml_fl_cur_size); + target_size = (live / 100 + 1) * (100 + caml_percent_free); target_size = caml_round_heap_chunk_size (target_size); if (target_size < caml_stat_heap_size / 2){ char *chunk; |