@@ -258,7 +258,7 @@ CAMLprim value caml_gc_major(value v)
258
258
return caml_raise_async_if_exception (gc_major_exn (0 ), "" );
259
259
}
260
260
261
- static value gc_full_major_exn (void )
261
+ static value gc_full_major_exn (int force_compaction )
262
262
{
263
263
int i ;
264
264
value exn = Val_unit ;
@@ -268,7 +268,7 @@ static value gc_full_major_exn(void)
268
268
currently-unreachable object to be collected. */
269
269
for (i = 0 ; i < 3 ; i ++ ) {
270
270
caml_empty_minor_heaps_once ();
271
- caml_finish_major_cycle (0 );
271
+ caml_finish_major_cycle (force_compaction && i == 2 );
272
272
exn = caml_process_pending_actions_exn ();
273
273
if (Is_exception_result (exn )) break ;
274
274
}
@@ -281,7 +281,7 @@ CAMLprim value caml_gc_full_major(value v)
281
281
{
282
282
Caml_check_caml_state ();
283
283
CAMLassert (v == Val_unit );
284
- return caml_raise_async_if_exception (gc_full_major_exn (), "" );
284
+ return caml_raise_async_if_exception (gc_full_major_exn (0 ), "" );
285
285
}
286
286
287
287
CAMLprim value caml_gc_major_slice (value v )
@@ -299,8 +299,7 @@ CAMLprim value caml_gc_compaction(value v)
299
299
Caml_check_caml_state ();
300
300
CAML_EV_BEGIN (EV_EXPLICIT_GC_COMPACT );
301
301
CAMLassert (v == Val_unit );
302
- value exn = gc_major_exn (1 );
303
- ++ Caml_state -> stat_forced_major_collections ;
302
+ value exn = gc_full_major_exn (1 );
304
303
CAML_EV_END (EV_EXPLICIT_GC_COMPACT );
305
304
return caml_raise_async_if_exception (exn , "" );
306
305
}
@@ -309,7 +308,7 @@ CAMLprim value caml_gc_stat(value v)
309
308
{
310
309
value res ;
311
310
CAML_EV_BEGIN (EV_EXPLICIT_GC_STAT );
312
- res = gc_full_major_exn ();
311
+ res = gc_full_major_exn (0 );
313
312
if (Is_exception_result (res )) goto out ;
314
313
res = caml_gc_quick_stat (Val_unit );
315
314
out :
0 commit comments