Linux BASH memory leak when redirecting stdio

2019-07-23 17:51发布

I've got a memory leak somewhere, but it doesn't appear to be related to my program. I'm making this bold statement based on the fact that once my program terminates, either by normal means, seg-faulting, or aborting, the memory isn't recovered. If my program were the culprit, I would assume the MMU would recover everything, but this doesn't appear to be the case.

The leak only comes into play when I redirect stdout (in BASH version 2.05 or 4) to a file, as in this is okay:

# my-program 

but this isn't:

# my-program > /mnt/sda1/log-output.txt

The rate at which I'm printing to the screen is < 2Kb/sec. (The file is on a USB key).

Any ideas?

A related question is here.

1条回答
再贱就再见
2楼-- · 2019-07-23 18:18

The MemFree alone says nearly nothing.

Linux's block layer caches a lot.

You can see how much is being used for filesystem (and other) caches in the same /proc/meminfo you have mentioned.

查看更多
登录 后发表回答