bzcat/zcat does eat huge amounts of memory.

Denys Vlasenko vda.linux at googlemail.com
Sat Apr 20 12:36:46 UTC 2019


On Fri, Apr 19, 2019 at 4:23 PM Markus Gothe <nietzsche at lysator.liu.se> wrote:
>
> Seems to me that the implementation is seriously flawed, it decompress the whole file into the heap and then print it out.

Can't reproduce:

$ ./busybox zcat 392mbyte_gzipped_file.gz >/dev/null & pid=$!; pmap
$pid; while pmap $pid; do sleep 1; done
30164:   ./busybox zcat 392mbyte_gzipped_file.gz
0000000008048000    960K r-x-- busybox
0000000008138000      4K rw--- busybox
0000000008139000      4K rw---   [ anon ]
00000000083f6000      4K rw---   [ anon ]
00000000f7741000     64K rw---   [ anon ]
00000000f7751000     12K r----   [ anon ]
00000000f7754000      8K r-x--   [ anon ]
00000000ffa06000    132K rw---   [ stack ]
 total             1188K
30164:   ./busybox zcat 392mbyte_gzipped_file.gz
0000000008048000    960K r-x-- busybox
0000000008138000      4K rw--- busybox
0000000008139000      4K rw---   [ anon ]
00000000083f6000      4K rw---   [ anon ]
00000000f7741000     64K rw---   [ anon ]
00000000f7751000     12K r----   [ anon ]
00000000f7754000      8K r-x--   [ anon ]
00000000ffa06000    132K rw---   [ stack ]
 total             1188K
30164:   ./busybox zcat 392mbyte_gzipped_file.gz
0000000008048000    960K r-x-- busybox
0000000008138000      4K rw--- busybox
0000000008139000      4K rw---   [ anon ]
00000000083f6000      4K rw---   [ anon ]
00000000f7741000     64K rw---   [ anon ]
00000000f7751000     12K r----   [ anon ]
00000000f7754000      8K r-x--   [ anon ]
00000000ffa06000    132K rw---   [ stack ]
 total             1188K
30164:   ./busybox zcat 392mbyte_gzipped_file.gz
0000000008048000    960K r-x-- busybox
0000000008138000      4K rw--- busybox
0000000008139000      4K rw---   [ anon ]
00000000083f6000      4K rw---   [ anon ]
00000000f7741000     64K rw---   [ anon ]
00000000f7751000     12K r----   [ anon ]
00000000f7754000      8K r-x--   [ anon ]
00000000ffa06000    132K rw---   [ stack ]
 total             1188K
...
...
30164:   ./busybox zcat 392mbyte_gzipped_file.gz
0000000008048000    960K r-x-- busybox
0000000008138000      4K rw--- busybox
0000000008139000      4K rw---   [ anon ]
00000000083f6000      4K rw---   [ anon ]
00000000f7741000     64K rw---   [ anon ]
00000000f7751000     12K r----   [ anon ]
00000000f7754000      8K r-x--   [ anon ]
00000000ffa06000    132K rw---   [ stack ]
 total             1188K

I see no memory usage growth. At all.


More information about the busybox mailing list