重定向stdio时,Linux BASH内存泄漏 [英] Linux BASH memory leak when redirecting stdio

查看:79
本文介绍了重定向stdio时,Linux BASH内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在某处内存泄漏 ,但这似乎与我的程序无关.我之所以做出这种大胆的声明,是基于以下事实:程序正常终止,段错误或中止后,程序将无法恢复.如果我的程序是罪魁祸首,我将假定MMU可以恢复所有内容,但事实并非如此.

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.

仅当我将stdout(在BASH版本2.05或4中)重定向到文件时,泄漏才起作用,因为这样就可以了:

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 

但这不是:

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

我在屏幕上打印的速度是< 2Kb/秒(该文件位于USB闪存盘上.)

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

有什么想法吗?

一个相关的问题是此处.

推荐答案

仅MemFree几乎什么也没说.

The MemFree alone says nearly nothing.

Linux的块层缓存很多.

Linux's block layer caches a lot.

您可以在与上述相同的/proc/meminfo中看到有多少文件系统(和其他)高速缓存正在使用.

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

这篇关于重定向stdio时,Linux BASH内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆