Ticket #1742: compact-pool-fix.diff

File compact-pool-fix.diff, 1.0 KB (added by nwellnhof, 4 years ago)
  • src/gc/alloc_resources.c

    diff --git a/src/gc/alloc_resources.c b/src/gc/alloc_resources.c
    index 2740f34..b7eaeda 100644
    a b  
    454454    if (mem_pools->gc_sweep_block_level) 
    455455        return; 
    456456 
     457    ++mem_pools->gc_sweep_block_level; 
     458 
     459    /* We're collecting */ 
     460    mem_pools->mem_allocs_since_last_collect    = 0; 
     461    mem_pools->header_allocs_since_last_collect = 0; 
    457462    ++mem_pools->gc_collect_runs; 
    458463 
    459464    /* Snag a block big enough for everything */ 
    460465    total_size = pad_pool_size(pool); 
    461466 
    462     if (total_size == 0) 
     467    if (total_size == 0) { 
     468        free_old_mem_blocks(mem_pools, pool, pool->top_block, total_size); 
     469        --mem_pools->gc_sweep_block_level; 
    463470        return; 
    464  
    465     ++mem_pools->gc_sweep_block_level; 
    466  
    467     /* We're collecting */ 
    468     mem_pools->mem_allocs_since_last_collect    = 0; 
    469     mem_pools->header_allocs_since_last_collect = 0; 
     471    } 
    470472 
    471473    alloc_new_block(mem_pools, total_size, pool, "inside compact"); 
    472474