Fix OOM while aggregating metrics