{"thread":{"id":"26637","subject":"[BUG] Out of memory in Git.pm","startedAt":"2011-03-02T13:01:43Z","lastAt":"2011-03-03T08:37:14Z","messageCount":2,"participants":["Robert Wruck","Alexander Miseler"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"162635","messageId":"4D6E3FB7.60600@tweerlei.de","threadId":"26637","inReplyTo":null,"subject":"[BUG] Out of memory in Git.pm","fromName":"Robert Wruck","fromEmail":"wruck@tweerlei.de","sentAt":"2011-03-02T13:01:43Z","receivedAt":"2011-03-02T13:01:43Z","isPatch":false,"sender":{"key":"wruck@tweerlei.de","avatar":null},"body":"Hi,\n\nthere seems to be a problem in Git.pm (git-1.7.4.1, sub cat_blob, line \n891) where the whole object is read into memory ($blob) before writing \nto $fh:\n\n\tmy $blob;\n\tmy $bytesRead = 0;\n\n\twhile (1) {\n\t\tmy $bytesLeft = $size - $bytesRead;\n\t\tlast unless $bytesLeft;\n\n\t\tmy $bytesToRead = $bytesLeft < 1024 ? $bytesLeft : 1024;\n\t\tmy $read = read($in, $blob, $bytesToRead, $bytesRead);\n\t\tunless (defined($read)) {\n\t\t\t$self->_close_cat_blob();\n\t\t\tthrow Error::Simple(\"in pipe went bad\");\n\t\t}\n\n\t\t$bytesRead += $read;\n\t}\n\nMaybe it would be better to write each chunk directly to $fh ?\nIf so, I could create a patch.\n\n-Robert\n"},{"id":"162710","messageId":"loom.20110303T093108-235@post.gmane.org","threadId":"26637","inReplyTo":"4D6E3FB7.60600@tweerlei.de","subject":"Re: [BUG] Out of memory in Git.pm","fromName":"Alexander Miseler","fromEmail":"alexander@miseler.de","sentAt":"2011-03-03T08:37:14Z","receivedAt":"2011-03-03T08:37:14Z","isPatch":false,"sender":{"key":"alexander@miseler.de","avatar":null},"body":"Robert Wruck <wruck <at> tweerlei.de> writes:\n> there seems to be a problem in Git.pm (git-1.7.4.1, sub cat_blob, line \n> 891) where the whole object is read into memory ($blob) before writing \n\n\nThere already seems to be a fix for this in \ngit://repo.or.cz/git/mingw/4msysgit.git but I couldn't find the commit in \ngit://git.kernel.org/pub/scm/git/git.git:\n\nAuthor:\t\tGregor Uhlenheuer (kongo2002@googlemail.com)\nAuthor date:\t13 days ago (Fri Feb 18 11:42:12 2011 +0100)\nCommitter:\tJohannes Schindelin (johannes.schindelin@gmx.de)\nCommit date:\t13 days ago (Fri Feb 18 17:09:08 2011 +0100)\nCommit hash:\te91fdbabfe29b6e37f1bc582316a82f7784a0275\n\n\nGit.pm: Use stream-like writing in cat_blob()\n\nThis commit fixes the issue with the handling of large files causing an\n'Out of memory' perl exception. Instead of reading and writing the whole\nblob at once now the blob is written in small pieces.\n\nThe problem was raised and discussed in this mail to the msysGit mailing\nlist: http://thread.gmane.org/gmane.comp.version-control.msysgit/12080\n\nSigned-off-by: Gregor Uhlenheuer <kongo2002@googlemail.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nContained in branches: devel\nContained in no tag\n"}]}