[BUG] Out of memory in Git.pm
- From
- Robert Wruck <wruck@tweerlei.de>
- Date
- Mar 2, 2011, 13:01 UTC
- Message-ID
- <4D6E3FB7.60600@tweerlei.de>
Hi,
there seems to be a problem in Git.pm (git-1.7.4.1, sub cat_blob, line 891) where the whole object is read into memory ($blob) before writing to $fh:
my $blob; my $bytesRead = 0;
while (1) {
my $bytesLeft = $size - $bytesRead;
last unless $bytesLeft; my $bytesToRead = $bytesLeft < 1024 ? $bytesLeft : 1024;
my $read = read($in, $blob, $bytesToRead, $bytesRead);
unless (defined($read)) {
$self->_close_cat_blob();
throw Error::Simple("in pipe went bad");
}$bytesRead += $read; }
Maybe it would be better to write each chunk directly to $fh ? If so, I could create a patch.
-Robert