Sfoglia il codice sorgente

Fix total free size calculation during reclaiming objects (#2510)

Xu Jun 2 anni fa
parent
commit
6de889b732
1 ha cambiato i file con 2 aggiunte e 8 eliminazioni
  1. 2 8
      core/shared/mem-alloc/ems/ems_gc.c

+ 2 - 8
core/shared/mem-alloc/ems/ems_gc.c

@@ -69,10 +69,7 @@ sweep_instance_heap(gc_heap_t *heap)
     hmu_type_t ut;
     gc_size_t size;
     int i, lsize;
-
-#if GC_STAT_DATA != 0
     gc_size_t tot_free = 0;
-#endif
 
     bh_assert(gci_is_heap_valid(heap));
 
@@ -116,9 +113,7 @@ sweep_instance_heap(gc_heap_t *heap)
         else {
             /* current block is still live */
             if (last) {
-#if GC_STAT_DATA != 0
                 tot_free += (char *)cur - (char *)last;
-#endif
                 gci_add_fc(heap, last, (char *)cur - (char *)last);
                 hmu_mark_pinuse(last);
                 last = NULL;
@@ -136,16 +131,15 @@ sweep_instance_heap(gc_heap_t *heap)
     bh_assert(cur == end);
 
     if (last) {
-#if GC_STAT_DATA != 0
         tot_free += (char *)cur - (char *)last;
-#endif
         gci_add_fc(heap, last, (char *)cur - (char *)last);
         hmu_mark_pinuse(last);
     }
 
+    heap->total_free_size = tot_free;
+
 #if GC_STAT_DATA != 0
     heap->total_gc_count++;
-    heap->total_free_size = tot_free;
     if ((heap->current_size - tot_free) > heap->highmark_size)
         heap->highmark_size = heap->current_size - tot_free;