c - 开发过程中的内存泄漏

标签 c memory-leaks

所以,我最近注意到,在完成某个项目的开发后,我们的开发服务器在 4GB 内存中稳定地剩余 ~300MB。假设这是由于开发阶段的内存泄漏,内存最终会自行释放还是需要重启服务器。将来是否有任何工具可用于防止这种情况发生(除了显而易见的“不要编写产生内存泄漏的代码”之外)?有时它们会消失一段时间,随着时间的推移,我猜它们会随着您继续测试您的应用而累积起来。

最佳答案

您运行的是什么操作系统?现在大多数操作系统都会在进程退出时清理进程的泄漏内存。您看到的正在使用的内存可能实际上被用于文件系统缓存。这没什么好担心的——操作系统会在必要时回收此内存。

发件人:http://learnlinux.tsf.org.za/courses/build/internals/ch05.html

The amount of free memory indicated by the free command includes the current size of the buffer cache in its calculation. This is misleading, as the amount of free memory indicated will often be very low, as the buffer cache soon fills most of user memory. Don't' panic. Applications are probably not crowding your RAM; it is merely the buffer cache that is taking up all available space. The buffer cache counts as memory space available for application use (remembering that it will be shrunk as required), so subtract the size of the buffer cache to see the real amount of free memory available for application use

关于c - 开发过程中的内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1676593/

相关文章:

c++ - 您如何在托管代码环境之外安全地进行编程?

iphone - 内存泄漏 - Objective-C

java - 是否可以检测堆外内存泄漏的根源?

c - 如何检查字符串是否以C中的某个字符串开头?

调用多个 _popen 失败

C 代码和条件的正确语法

c# - 在 c# 中加载 1000 张图像而不会出现内存不足异常

ios - 在后台线程上使用CoreGraphics调整图像大小时发生内存泄漏

c - 'printf' 后跟 'scanf' 需要按两次 ENTER 键才能接受输入

c - fork() 为什么不是无限输出