检测用C内存泄漏 [英] detecting memory leak in C

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

问题描述

我知道这是不是一个新问题,但我没有发现任何其他地方工作。
我有一个C程序因为它运行平稳吃​​记忆 - 我用的是'自由'命令跟踪它,我可以看到,只要它执行可用内存量正在减少,这不应该发生。但是,我无法找到,可能会造成这个程序本身什么。我也用的valgrind和dmalloc对其进行了测试,其中幽冥能够探测到任何记忆丧失。

I know this is hardly a new question, but I haven't found anything elsewhere that works. I've got a C program that steadily eats memory as it runs - I use the 'free' command to track it, and I can see the amount of available memory is decreasing as long as it executes, which shouldn't be happening. However, I can't find anything in the program itself that could be causing this. I've also tested it with valgrind and dmalloc, and nether of them are able to detect any memory loss.

我如何找到泄漏?

推荐答案

如果你不确定的的内存使用情况,也许它不是的的mallocs并释放了都是问题。

If you're sure about your usage of memory, perhaps it's not your mallocs and frees that are the problem.

如果你使用任何库,你应该仔细检查您正确使用它们。许多人初始化和释放功能,你可以很容易忘记,从而导致内存泄漏(S)。

If you're using any libs, you should double-check that you use them correctly. Many have initialisation and freeing functions that you can easily forget, and thus cause memory leak(s).

这篇关于检测用C内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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