git gc 使用内存过多,无法完成

发布于 2024-12-17 06:47:31 字数 2327 浏览 3 评论 0原文

最终更新和修复:这里的解决方案是两件事的组合:使用 Windows Git 而不是 Cygwin Git 作为 Graham Borland 建议,以及 Git 配置设置pack.threads = 1gc.aggressiveWindow = 150

我有一个大型本地 Git 存储库,一个 git svn clone一个包含大约 40,000 次提交的 SVN 存储库。我试图在这个存储库上运行 git gc ,但一无所获:

$ git gc --auto
Auto packing the repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
Counting objects: 25966, done.
Compressing objects: 100% (25249/25249), done.
fatal: Out of memory, malloc failed (tried to allocate 426523986 bytes)
error: failed to run repack

我在一台 4GB RAM 的 64 位双核 Win7 机器上的 Cygwin 中运行 Git 1.7.5.1。 .git 目录目前略高于 6.1GB。

我尝试运行 git gc --aggressive ,看看更完整的系统是否能够修复它,但没有运气:我收到了与上面类似的消息,尝试了相同的大小< code>malloc,但对象数量要高得多(计数为 508,485,压缩为 493,506)。

我还尝试过(按照 Google 的建议)对我的 .gitconfig 文件的 [pack] 部分进行各种调整;最完整的是另一个 StackOverflow 问题。我的 .gitconfig 现在有以下相关行,但设置这些似乎没有什么区别:

[pack]
        windowMemory = 16m
        threads = 1
        window = 1
        depth = 1
        deltaCacheSize = 1

有关如何将 git 获取到 gc 的任何建议> 我的存储库?

编辑Mark Longair 建议.gitconfig 文件进行更多更改。这是我做的,下面是新行。但这些变化没有任何区别。

[core]
        packedGitWindowSize = 1m
        packedGitLimit = 256m
[pack]
        packSizeLimit = 128m

编辑2Michael Krelin 建议增加交换/页面文件大小(WinXP 说明

我现在正在研究这是否是由 Cygwin 内部或强加的内存限制引起的。为了检查“强加”,我尝试以管理员权限运行 Cygwin。为了检查“内部”(看起来更有可能),我正在玩 Cygwin 的最大内存设置

编辑 3:虽然我可能更喜欢使用 Cygwin,但事实证明 Windows Git 客户端可以很好地处理内存问题。当我的存储库需要清理时,似乎我会经常回到这个状态。

Final update and fix: The solution here turned out to be a combination of two things: using Windows Git rather than Cygwin Git as Graham Borland suggested, and the Git config settings pack.threads = 1 and gc.aggressiveWindow = 150.

I have a large local Git repository, a git svn clone of an SVN repository with about 40,000 commits. I'm trying to run git gc over this repository, and getting nowhere:

$ git gc --auto
Auto packing the repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
Counting objects: 25966, done.
Compressing objects: 100% (25249/25249), done.
fatal: Out of memory, malloc failed (tried to allocate 426523986 bytes)
error: failed to run repack

I'm running Git 1.7.5.1 inside Cygwin on a 64-bit dual-core Win7 machine with 4GB RAM. The .git directory is currently a little over 6.1GB.

I've tried running git gc --aggressive, to see if the more complete system is able to fix it, but no luck: I get a similar message to the above, with the same size attempted malloc, but a considerably higher object count (508,485 counted, 493,506 compressed).

I've also tried—as suggested by Google—assorted twiddles to the [pack] part of my .gitconfig file; the most complete being from another StackOverflow question. My .gitconfig now has the following relevant lines, but setting these appears to have made no difference:

[pack]
        windowMemory = 16m
        threads = 1
        window = 1
        depth = 1
        deltaCacheSize = 1

Any suggestions on how I can get git to gc my repository?

Edit: Mark Longair suggested some more .gitconfig file changes. Which I made, new lines below. But the changes made no difference whatsoever.

[core]
        packedGitWindowSize = 1m
        packedGitLimit = 256m
[pack]
        packSizeLimit = 128m

Edit 2: Michael Krelin suggested increasing the swap/page file size (WinXP instructions here, and it's similar for Win7). I tried that, but it made no difference, and indeed I only increased the maximum size available, and it looks as if Windows never tried to increase the size of the page file it was using.

I'm now looking at whether this was caused by a memory limit within or imposed upon Cygwin. To check "imposed upon", I'm trying running Cygwin with administrator privileges. To check "within" (which looks more likely), I'm having a play with Cygwin's maximum memory settings.

Edit 3: Much though I may prefer using Cygwin, it turns out the Windows Git client deals with the memory issue just fine. Seems I'll be falling back to that every so often when my repository needs a tidy.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

孤独陪着我 2024-12-24 06:47:31

我遇到了同样的问题,尝试了到目前为止提到的解决方案,但没有成功。但是在我将大图像文件添加到存储库后,我的 git gc 问题开始出现,因此我创建了 .gitattributes 文件并关闭了这些大文件的增量压缩:

*.tga -delta
*.psd -delta

它起作用了。

I had the same problem, tried the solutions mentioned so far without success. But my problems with git gc began after I added big image files to repo, so I created .gitattributes file and turned off delta compression for those big files:

*.tga -delta
*.psd -delta

It worked.

↙温凉少女 2024-12-24 06:47:31

您可能会更幸运地运行本机 Windows 客户端,例如 msysGit,而不是尝试在 Cygwin 中执行此操作。

You might have more luck running a native Windows client such as msysGit, rather than trying to do it inside Cygwin.

岁月静好 2024-12-24 06:47:31

您可能想要尝试限制为低于默认值的其他一些配置选项包括:

  • pack.packSizeLimit
  • core.packedGitWindowSize
  • core.packedGitLimit

..所有这些都记录在git config文档。特别值得检查的是在每种情况下都理解了哪些单位,这是我过去犯过的错误。

Some other config options that you might want to try restricting to lower than default values include:

  • pack.packSizeLimit
  • core.packedGitWindowSize
  • core.packedGitLimit

... all of which are documented in the git config documentation. It's particularly worth checking in each case what units are understood, which I've made mistakes with in the past.

旧街凉风 2024-12-24 06:47:31

唯一有助于避免共享 Linux 主机上出现此错误的方法是添加

  [pack]
    packSizeLimit = 64m
    threads = 1

.gitconfig

最重要的是“threads = 1”

The only thing that help to avoid this error on shared Linux hosting was to add

  [pack]
    packSizeLimit = 64m
    threads = 1

to

.gitconfig

Most important was "threads = 1"

烙印 2024-12-24 06:47:31

也许暂时添加一个比生活更大的交换文件并去其他地方喝几杯咖啡会有所帮助?

Maybe temporarily adding a swap file bigger than life and going for a few cups of coffee elsewhere will help?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文