summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-02-04 04:56:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2023-02-04 04:56:44 (GMT)
commitbfd45094c4a95d8e2db54600afa4d32edd6d75b2 (patch)
tree25ea0c88b0322661f121c7db6837a08dac8120ab
parent88ce39d2f9add4beb3427d4178d1cdbe00ac1716 (diff)
parent647982bb7171b2409f2a90da245b8a31913f930f (diff)
downloadgit-next.zip
git-next.tar.gz
git-next.tar.bz2
Merge branch 'ew/free-island-marks' into nextnext
"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
-rw-r--r--builtin/pack-objects.c4
-rw-r--r--delta-islands.c14
-rw-r--r--delta-islands.h1
3 files changed, 18 insertions, 1 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index cabace4..3395f63 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -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;
diff --git a/delta-islands.c b/delta-islands.c
index 90c0d69..8b234cb 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -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;
diff --git a/delta-islands.h b/delta-islands.h
index eb0f952..8d1591a 100644
--- a/delta-islands.h
+++ b/delta-islands.h
@@ -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 */