Linux BASH memory leak when redirecting stdio

情到浓时终转凉″ 提交于 2019-12-23 23:13:17

问题


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:


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.



来源:https://stackoverflow.com/questions/1545530/linux-bash-memory-leak-when-redirecting-stdio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!