- 3
- 0
- 约1.45万字
- 约 7页
- 2018-06-12 发布于贵州
- 举报
Fixing Memory Problems
This chapter is about finding bugs in C/C++ programs with the help of a memory
debugger. A memory debugger is a runtime tool designed to trace and detect bugs
in C/C++ memory management and access. It does not replace a general debugger.
In the following sections, we will describe the memory access bugs that typically
occur in C/C++ programs, introduce memory debuggers, and show with two examples
how these tools find bugs. We will then show how to run memory and source
code debuggers together, how to deal with unwanted error messages by writing a
suppression file, and what restrictions need to be considered.
4.1 Memory Management in C/C++ – Powerful but Dangerous
The C/C++ language is able to manage memory resources, and can access memory
directly through pointers. Efficient memory handling and “programming close to the
hardware” are reasons why C/C++ replaced assembly language in the implementation
of large software projects such as operating systems, where performance and
low overhead play a major role. The allocation of dynamic memory (also known as
heap memory) in C/C++ is under the control of the programmer. New memory is
allocated with functions such as malloc() and various forms of the operator new.
Unused memory is returned with free() or delete.
The memory handling in C/C++ gives a large degree of freedom, control, and
performance, but comes at a high price: the memory access is a frequent source of
bugs. The most frequent sources of memory access bugs are memory leaks, incorrect
use of memory management, buffer overruns, and reading uninitialized memory.
33
34 4 Fixing Memory Problems
4.1.1 Memory Leaks
Memory leaks are data structures that are allocated at runtime, but not deallocated
once they are no longer needed in the program. If the leaks are frequent or large,
eventually all available main memory in your computer will be consumed. The program
will first slow down, as the computer starts swapping pages to virtual memory,
and th
您可能关注的文档
- 老年人口腔保健ppt课件.ppt
- 老年人颅脑外伤诊治原则ppt课件图文.ppt
- 老年保健PPT课件.ppt
- 老年养生保健ppt课件.ppt
- 老年保健课 睡眠问题ppt课件.ppt
- 老年康复概论ppt课件.ppt
- 老年房颤抗凝PPT课件.ppt
- 老年人常见疾病护理知识3PPT课件.pptx
- 老年抑郁症的诊疗进展 ppt课件.ppt
- 缺血性脑血管病诊治进展方案课件.ppt
- 全过程工程管理造价咨询工程监理项目服务方案投标方案(技术部分).doc
- 招标代理服务投标技术服务方案(技术方案).doc
- AI大模型与AIGC技术在公安领域的应用解决方案(99页 PPT).pptx
- 工业4.0智能制造数字工厂规划方案.pptx
- 树立社会主义核心价值观.docx
- 三年(2023-2025)中考历史真题分类汇编(全国)专题21 科技文化与社会生活(解析版).docx
- 2025年中考道德与法治真题完全解读(吉林卷).pdf
- 2025年中考道德与法治真题完全解读(安徽卷).pdf
- 三年(2023-2025)中考历史真题分类汇编(全国)专题14 人民解放战争(解析版).pdf
- 三年(2023-2025)广东中考历史真题分类汇编:专题03 中国近代史(八年级上册)(解析版).docx
最近下载
- 安徽省芜湖市弋江区2023-2024学年六上数学期末统考模拟试题含答案.doc VIP
- 组织学和胚胎学泌尿系统.pdf VIP
- 2025年高性能复合材料在新能源储能设备中的应用研究报告.docx
- 医疗器械用复合材料市场分析报告:2025年现状与未来五到十年趋势展望.docx
- 《2025年工程机械行业复合材料应用前景分析报告》.docx
- GB∕T 40112-2021 地质灾害危险性评估规范.pdf
- 2025年海洋工程装备高性能复合材料研发与应用创新报告.docx
- 2025年中国睡眠研究报告.docx VIP
- 人教版三年级上册数学期末卷-小学数学三年级上册-期末复习试卷-人教版---.docx VIP
- 2025-2026学年高二物理期末模拟卷01【测试范围:人教版选必一+选必二】(考试版)(新高考通用).docx VIP
原创力文档

文档评论(0)