@@ -82,10 +82,20 @@ static void reset_table (struct generic_table *tbl)
82
82
tbl -> base = tbl -> ptr = tbl -> threshold = tbl -> limit = tbl -> end = NULL ;
83
83
}
84
84
85
- static void clear_table (struct generic_table * tbl )
85
+ static void clear_table (struct generic_table * tbl ,
86
+ asize_t element_size ,
87
+ const char * name )
86
88
{
89
+ asize_t maxsz = Caml_state -> minor_heap_wsz ;
90
+ if (tbl -> size <= maxsz ) {
87
91
tbl -> ptr = tbl -> base ;
88
92
tbl -> limit = tbl -> threshold ;
93
+ } else {
94
+ caml_gc_message (0x08 , "Shrinking %s to %ldk bytes\n" ,
95
+ name ,
96
+ (long )((maxsz * element_size ) / 1024 ));
97
+ alloc_generic_table (tbl , Caml_state -> minor_heap_wsz , 256 , element_size );
98
+ }
89
99
}
90
100
91
101
struct caml_minor_tables * caml_alloc_minor_tables (void )
@@ -448,9 +458,15 @@ void caml_empty_minor_heap_domain_clear(caml_domain_state* domain)
448
458
449
459
caml_final_empty_young (domain );
450
460
451
- clear_table ((struct generic_table * )& minor_tables -> major_ref );
452
- clear_table ((struct generic_table * )& minor_tables -> ephe_ref );
453
- clear_table ((struct generic_table * )& minor_tables -> custom );
461
+ clear_table ((struct generic_table * )& minor_tables -> major_ref ,
462
+ sizeof (value * ),
463
+ "major_ref" );
464
+ clear_table ((struct generic_table * )& minor_tables -> ephe_ref ,
465
+ sizeof (struct caml_ephe_ref_elt ),
466
+ "ephe_ref" );
467
+ clear_table ((struct generic_table * )& minor_tables -> custom ,
468
+ sizeof (struct caml_custom_elt ),
469
+ "custom" );
454
470
455
471
domain -> extra_heap_resources_minor = 0.0 ;
456
472
}
0 commit comments