[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#7357: csplit: memory exhausted when using stdout / pipe instead of a
From: |
Pádraig Brady |
Subject: |
bug#7357: csplit: memory exhausted when using stdout / pipe instead of a file |
Date: |
Wed, 10 Nov 2010 10:51:37 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 |
On 09/11/10 15:46, Pádraig Brady wrote:
> On 09/11/10 11:02, Blinker| David Hofstee wrote:
>> Hi,
>>
>>
>>
>> When I try to use csplit via stdout from zcat I get the message 'csplit:
>> memory exhausted'. The .gz file is a mysql dump from its databases (one
>> is particularly large):
>
> Yes csplit currently doesn't use a fixed size buffer.
> We need to fix that up.
>
> $ (ulimit -v 100000; yes | ~/git/coreutils/src/csplit - /n/)
> /home/padraig/git/coreutils/src/csplit: memory exhausted
> 23284170
I just looked at the csplit code there,
and it's more sophisticated than I expected.
Therefore it seems this is just a plain old mem leak.
diff --git a/src/csplit.c b/src/csplit.c
index 40baba8..770f891 100644
--- a/src/csplit.c
+++ b/src/csplit.c
@@ -418,6 +418,13 @@ get_new_buffer (size_t min_size)
static void
free_buffer (struct buffer_record *buf)
{
+ struct line *l, *n;
+ for (l = buf->line_start; l;)
+ {
+ n = l->next;
+ free (l);
+ l = n;
+ }
free (buf->buffer);
buf->buffer = NULL;
}
@@ -542,6 +549,7 @@ remove_line (void)
if (prev_buf)
{
free_buffer (prev_buf);
+ free (prev_buf);
prev_buf = NULL;
}
- bug#7357: csplit: memory exhausted when using stdout / pipe instead of a file, Blinker| David Hofstee, 2010/11/09
- bug#7357: csplit: memory exhausted when using stdout / pipe instead of a file, Pádraig Brady, 2010/11/09
- bug#7357: csplit: memory exhausted when using stdout / pipe instead of a file,
Pádraig Brady <=
- bug#7357: csplit: memory exhausted when using stdout / pipe instead of a file, Jim Meyering, 2010/11/10
- bug#7357: csplit: memory exhausted when using stdout / pipe instead of a file, Pádraig Brady, 2010/11/10
- bug#7357: csplit: memory exhausted when using stdout / pipe instead of a file, Jim Meyering, 2010/11/10
- bug#7357: csplit: memory exhausted when using stdout / pipe instead of a file, Pádraig Brady, 2010/11/10
- bug#7357: csplit: memory exhausted when using stdout / pipe instead of a file, Jim Meyering, 2010/11/10
- bug#7357: csplit: memory exhausted when using stdout / pipe instead of a file, Pádraig Brady, 2010/11/10
- bug#7357: csplit: memory exhausted when using stdout / pipe instead of a file, Bob Proulx, 2010/11/10
- bug#7357: csplit: memory exhausted when using stdout / pipe instead of a file, Jim Meyering, 2010/11/11
- bug#7357: csplit: memory exhausted when using stdout / pipe instead of a file, Paul Eggert, 2010/11/10
- bug#7357: csplit: memory exhausted when using stdout / pipe instead of a file, Eric Blake, 2010/11/10