{"thread":{"id":"58048","subject":"Bug report. Out of memory about git checkout.","startedAt":"2022-06-22T13:53:43Z","lastAt":"2022-06-22T13:53:43Z","messageCount":1,"participants":["void f"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"457695","messageId":"CADRR3BF7rY0Z3UTJf223+ALns06Re+vxeNuhx9sKNFxu73=EWw@mail.gmail.com","threadId":"58048","inReplyTo":null,"subject":"Bug report. Out of memory about git checkout.","fromName":"void f","fromEmail":"fv729164860@gmail.com","sentAt":"2022-06-22T13:53:26Z","receivedAt":"2022-06-22T13:53:43Z","isPatch":false,"sender":{"key":"fv729164860@gmail.com","avatar":null},"body":"How to repeat:\n\nenv:\n\ngit version: 2.36.1\nos : center os\nmemory 8G\n\nWhen you execute \"git checkout .” to chekout a very large lfs-file,\nWhich is larger than your memory. It would throw “Out of memory,\nrealloc failed” exception.\n\n\nreason of the bug:\n\n\nWhen you execute git checkout, Which have to checkout a lfs-file to\nthe worktree. Git would execute \"convert.c apply_multi_file_filter()\"\nto convert lfs pointer from git-object to the lfs file. It will\nexecute a subprocess to convert this file. But It is strange that git\nwould read all of the file into memory When finish the git-lfs\nsubprocess. (The code is about pkt-line.c\nread_packetized_to_strbut()). Lfs usually is a very large file even\nmore than the memory. So it would throw out of memory exception.\n\nWith this bug, it would have trouble to use sparse-chekout in a\nrepository with large lfs-file. Because you must init the repository\nfirst and set the sparse-chekout config, than use git\npull/merge/checkout to checkout your subset worktree. It would out of\nmemory when you checkout it.\n\nI think git don’t need to read all of the file in memory. It can use a\nstream to finish the checkout.\n"}]}