ARM/Linux内存泄漏:终止后,用户程序可以保留内存吗? [英] ARM/Linux memory leak: Can a user program retain memory after terminating?
问题描述
我在某处内存泄漏 ,但这似乎与我的程序无关.我之所以做出这种大胆的声明,是基于以下事实:一旦我的程序因段错误,退出或中止而终止,内存将无法恢复.如果我的程序是罪魁祸首,我将假定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 seg-faulting, exitting, 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.
我的问题是:
在运行仅使用堆栈内存和几次对malloc()
的调用的程序的小型Linux系统(64 Mb Ram)上,我的原因也可能导致内存耗尽并在我的程序运行后立即消失终止?
On a small Linux system (64 Mb Ram) running a program that uses only stack memory and a few calls to malloc()
, what causes can I look too see memory being run down and stay down once my program terminates?
一个相关的问题是此处:
当有问题的代码将其stdout,stderr定向到文件后,一切就开始了.几个小时后,它因分段错误"而中止.快速(天真?)查看/proc/meminfo显示没有足够的可用内存,因此我认为有些东西正在泄漏.
This all started when after code in question was directing its stdout, stderr to a file. After a few hours it aborted with a "Segmentation Fault". A quick (naive?) look at /proc/meminfo showed that there wasn't much available memory, so I assumed something was leaking.
推荐答案
It appears I don't have a memory leak (see here) but it does lead me to some new questions...
事实证明,写入块设备可能会使用大量的物理内存.在我的系统中,只有64 Meg,因此向USB驱动器写入数百Meg会大大增加缓存,活动和非活动内存池.
It turns out that writing to block devices can use a quite a pile of physical memory; in my system there was only 64 Meg, so writing hundreds of Megs to a USB drive was increasing the cached, active and inactive memory pools quite a bit.
卸装设备后,这些内存池将立即释放到可用内存池中.
These memory pools are immediately released to the Free memory pool when the device is dismounted.
我的分段错误的确切原因仍然是一个谜,但是我知道可以通过更好地了解虚拟内存资源来减少这种情况的发生,尤其是在使用Block设备的情况下.
The exact cause of my segmentation fault remains a small mystery, but I know it's occurence can be reduced by understanding the virtual memory resources better, particularly around the use of Block devices.
这篇关于ARM/Linux内存泄漏:终止后,用户程序可以保留内存吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!