在C程序中查找内存泄漏的最佳方法 [英] Best way to find memory leaks in a C program
本文介绍了在C程序中查找内存泄漏的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试完成大学作业,并且评分标准指定了5%的内存管理-特别是对于没有内存泄漏的情况.
I am trying to complete a college assignment, and the marking criteria specifies 5% for memory management - specifically for having no memory leaks.
据我了解,简单C程序中的内存泄漏仅是由已被程序放弃的指针引起的,即,从未具有相应free
的malloc/calloc/etc调用.
As I understand it, memory leaks in simple C programs, are only caused by pointers which have become abandoned by the program - ie, malloc/calloc/etc calls which are never have a corresponding free
.
我的问题分为三个部分:
My question is in 3 parts:
- 在Solaris上最简单的方法是什么 和OSX来证明"您还没有 泄漏了任何内存?
- XCode是否具有 任何有助于确定记忆的工具 泄漏?
- 执行操作系统 释放所有先前分配的 一旦在C程序中的内存 程序结束了吗?
- Whats the simplest way on Solaris and OSX to 'prove' that you haven't leaked any memory?
- Does XCode have any tools to help determine memory leaks?
- Does the operating system release all previously allocated memory within a c program once the process ends?
推荐答案
Valgrind 是你的朋友.
这篇关于在C程序中查找内存泄漏的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文