Merge branch 'ew/free-island-marks'

"git pack-objects" learned to release delta-island bitmap data when
it is done using it, saving peak heap memory usage.

* ew/free-island-marks:
  delta-islands: free island_marks and bitmaps
This commit is contained in:
Junio C Hamano 2023-02-09 14:40:47 -08:00
commit 6d1b2e48fe
3 changed files with 18 additions and 1 deletions

View file

@ -929,8 +929,10 @@ static struct object_entry **compute_write_order(void)
*/
for_each_tag_ref(mark_tagged, NULL);
if (use_delta_islands)
if (use_delta_islands) {
max_layers = compute_pack_layers(&to_pack);
free_island_marks();
}
ALLOC_ARRAY(wo, to_pack.nr_objects);
wo_end = 0;

View file

@ -513,6 +513,20 @@ void propagate_island_marks(struct commit *commit)
}
}
void free_island_marks(void)
{
struct island_bitmap *bitmap;
kh_foreach_value(island_marks, bitmap, {
if (!--bitmap->refcount)
free(bitmap);
});
kh_destroy_oid_map(island_marks);
/* detect use-after-free with a an address which is never valid: */
island_marks = (void *)-1;
}
int compute_pack_layers(struct packing_data *to_pack)
{
uint32_t i;

View file

@ -14,5 +14,6 @@ void resolve_tree_islands(struct repository *r,
void load_delta_islands(struct repository *r, int progress);
void propagate_island_marks(struct commit *commit);
int compute_pack_layers(struct packing_data *to_pack);
void free_island_marks(void);
#endif /* DELTA_ISLANDS_H */