# Garbage collection creates many unpacked objects.

2 messages from 2011-10-10 to 2011-10-10. Participants: Martin Fick, Shawn Pearce.
Thread: https://gitlist.dev/t/28643

## Martin Fick, 2011-10-10 23:30

Subject: Garbage collection creates many unpacked objects.
Message-ID: <201110101730.43302.mfick@codeaurora.org>
URL: https://gitlist.dev/e/201110101730.43302.mfick%40codeaurora.org

```
If I clone linus' kernel, delete all the tags, and then run 
git gc, it ends up expanding into about 5K of unpacked 
objects.  The .git size goes from 473M to 511M.  This seems 
a bit strange no?  Shouldn't gcing yield a smaller repo an 
fewer unpacked refs?

If I do this on our internal kernel repo (which has 2Ktags), 
it gets much more pathological, it expands to about 1M 
objects and grows to about 7G!!!

This seems to happen with all versions which I tested, 
1.6.0, 1.7.6 and 1.7.7

Any thoughts?

-Martin

-- 
Employee of Qualcomm Innovation Center, Inc. which is a 
member of Code Aurora Forum

```

## Shawn Pearce, 2011-10-10 23:49

Subject: Re: Garbage collection creates many unpacked objects.
Message-ID: <CAJo=hJtGyaudyL63AcaG=y4fvfO8Ka3pn=Orta-imb6AUXO6XA@mail.gmail.com>
URL: https://gitlist.dev/e/CAJo%3DhJtGyaudyL63AcaG%3Dy4fvfO8Ka3pn%3DOrta-imb6AUXO6XA%40mail.gmail.com
In-Reply-To: <201110101730.43302.mfick@codeaurora.org>

```
On Mon, Oct 10, 2011 at 16:30, Martin Fick <mfick@codeaurora.org> wrote:
> If I clone linus' kernel, delete all the tags, and then run
> git gc, it ends up expanding into about 5K of unpacked
> objects.  The .git size goes from 473M to 511M.  This seems
> a bit strange no?  Shouldn't gcing yield a smaller repo an
> fewer unpacked refs?
>
> If I do this on our internal kernel repo (which has 2Ktags),
> it gets much more pathological, it expands to about 1M
> objects and grows to about 7G!!!

This is caused by unreachable objects being evicted from packs and
stored as loose objects for up to 2 weeks, until the next `git prune`
run. I think you can avoid this by using `git repack -a -d` instead of
`git gc`, but at the risk that a concurrent modification of the
repository may result in corruption due to a race condition between
the object being needed, and the object being deleted.

```
