共查询到19条相似文献,搜索用时 156 毫秒
1.
内存管理是计算机编程最为基本的领域之一。在很多脚本语言中,不必担心内存是如何管理的,这并不能使得内存管理的重号性有一点点降低。对实际编程来说,理解内存管理器的能力与局限性至关重要。在大部分系统语言中,比如C和C++,必须进行内存管理。本文将介绍C/C++内存管理的基本技术及应用。C++中涉及到的内存的管理问题可以归结为两方面:正确地得到它和有效地使用它。“正确地得到”的意思是正确地调用内存分配和释放程序;而“有效地使用”指写特定版本的内存分配和释放程序。 相似文献
2.
在航天领域中,安全关键的大型实时软件系统往往直接影响到任务成败,一般难以全面检测、分析或避免内存泄漏等常见内存错误。定义了实时软件的12种典型内存故障模式,提出了一种基于C++代码插装的实时软件内存错误快速分析方法。该方法通过对C++源代码进行静态分析,获取指针变量相关信息;通过C++代码插装和运行不同测试用例,实时收集统计C++指针对象的分配、释放、赋值、c-use和p-use使用情况,结合实时软件的典型内存故障模式进行分析,并自动生成详情报告。应用案例表明,该方法能够高效快捷地发现实时软件潜在的典型内存错误,从而有效提高软件质量。 相似文献
3.
4.
5.
邓谱 《计算机光盘软件与应用》2010,(2):55-56
C++支持类的多继承,java采用类的单继承;C++中引入构造函数的同时也引入了析构函数,而java却没有析构函数,它自动进行无用内存回收操作,不需要程序员进行删除,而C++中必须由程序释放内存资源。本文将从一些常见的技术角度入手,对这两种程序设计语言进行阐述。 相似文献
6.
李朝中 《电脑编程技巧与维护》2009,(17):15-22
在用VC开发时,常常需要对内存进行操作,其中C++中提供了运算符new与delete;而C语言库中提供有malloc和free。它们在具体使用时存在着一些差别,文中主要解析VC6.0中为类对象申请内存的过程。 相似文献
7.
内存错误调试在二十年来一直困扰着C/C++开发人员,嵌入式行业显得更为突出,在龙芯SOC在产业化过程中.这个难题也一直没有很好解决。探讨网络计算机系统的可能存在的内存问题,以及传统手工排错的局限性。把Valgrind内存调试技术引入到嵌入式软件调试,比较完善地解决了内存泄露这类调试难题。 相似文献
8.
杨金良 《电脑编程技巧与维护》2010,(8):3-4,11
Symbian操作系统中,使用TRAP机制捕获系统异常,控制内存分配过程。清除栈结构可以保证当发生异常产生的情况下,系统不会出现内存泄露。对自定义类型的两段构造方法,可以修改C++默认的构造规则,保证内存安全。 相似文献
9.
该文主要探讨了C++语言教学中在数组使用、动态内存管理、指针使用、浅拷贝等方面应注意的若干问题,并指出正确的处理方法,最后介绍了C++/CLR中的内存管理机制。 相似文献
10.
C/C 语言中的动态内存管理机制自由且灵活,但动态内存的使用容易引入内存泄漏,导致系统性能降低甚至系统崩溃。为了更加有效的检测内存泄漏,提出了一个基于有界模型检测技术的C/C 程序内存泄漏检测方案MLD-CBMC。该方案以C/C 程序文件为输入,利用有界模型检测技术,对程序进行展开处理,加入内存泄漏性质,并利用可满足性模理论(SMT)对程序约束和性质组成的验证条件编码,使用SMT求解器对验证条件求解,将检测内存泄漏问题转换为求解可满足性问题,实现C/C 程序内存泄漏的检测。通过实验验证了方案的有效性,并与其他有界模型检测工具进行对比实验,实验证明方案对内存泄漏的检测能力更强。 相似文献
11.
存储一致性模型对共享存储系统的正确性,性能以及程序的复杂性都有重要的影响,该文立足于分布共享存储系统,提出了一种新的存储一致性模型框架-S^3C框架,该框架通过同步点的概念来描述不同模型正确的存储访问事件顺序;通过一致性维护点的概念,对同一模型的不同实现方式也能够进行区别和比较,结合S^3C框架,该文提出一种以操作系统为中心的线程一致性模型,并针对以顺序一致性模为代表的存储一致性模型的正确实现进行了论述。 相似文献
12.
This article presents the formal verification, using the Coq proof assistant, of a memory model for low-level imperative languages
such as C and compiler intermediate languages. Beyond giving semantics to pointer-based programs, this model supports reasoning
over transformations of such programs. We show how the properties of the memory model are used to prove semantic preservation
for three passes of the Compcert verified compiler. 相似文献
13.
This paper presents a memory model with nonoverlapping memory areas (regions) for the deductive verification of C programs. This memory model uses a core language that supports arbitrary nesting of structures, unions, and arrays into other structures and allows reducing the number of user-provided annotations as a result of region analysis. This paper also describes semantics of the core language and normalizing transformations for translating an input annotated C program into a program in the core language. In addition, an encoding is proposed for modeling the memory state of a core-language program with logical formulas as described by the model semantics of the core language. For the model semantics, the soundness and completeness theorems are proved. Additional constraints on the typing context of the core-language terms are described that determine the result of the region analysis enabling the complete modeling of a limited class of programs without using additional annotations. A proof sketch for the theorem stating completeness of the proposed region analysis for a limited class of programs is presented. 相似文献
14.
15.
Disassembly has become an important issue recently, as people begin to be concerned about the environment and natural resources. Many methodologies have been used to tackle disassembly problems. Design for disassembly (DFD) and planning for disassembly (PFD) are the two main approaches to address such problems. The focus of this paper is on PFD. To assist planners to solve PFD problems, a system must have some heuristics and domain specific knowledge, which is related to the representation of the disassembly knowledge. In previous work, the authors proposed to use EMOPs (eposodic memory organization packet) for the knowledge representation of the PFD plan. This paper presents the implementation of the EMOP memory model. The model has been implemented in C++. Examples are presented to demonstrate the capabilities of the memory model. 相似文献
16.
Harvey Tuch 《Journal of Automated Reasoning》2009,42(2-4):125-187
Systems code is almost universally written in the C programming language or a variant. C has a very low level of type and memory abstraction and formal reasoning about C systems code requires a memory model that is able to capture the semantics of C pointers and types. At the same time, proof-based verification demands abstraction, in particular from the aliasing and frame problems. In this paper we present a study in the mechanisation of two proof abstractions for pointer program verification in the Isabelle/HOL theorem prover, based on a low-level memory model for C. The language’s type system presents challenges for the multiple independent typed heaps (Burstall-Bornat) and separation logic proof techniques. In addition to issues arising from explicit value size/alignment, padding, type-unsafe casts and pointer address arithmetic, structured types such as C’s arrays and structs are problematic due to the non-monotonic nature of pointer and lvalue validity in the presence of the unary &-operator. For example, type-safe updates through pointers to fields of a struct break the independence of updates across typed heaps or ∧*-conjuncts. We provide models and rules that are able to cope with these language features and types, eschewing common over-simplifications and utilising expressive shallow embeddings in higher-order logic. Two case studies are provided that demonstrate the applicability of the mechanised models to real-world systems code; a working of the standard in-place list reversal example and an overview of the verification of the L4 microkernel’s memory allocator. 相似文献
17.
C程序中数组、malloc动态分配后的连续内存等顺序存储结构被大量使用,但大多数传统的数据流分析方法未能充分描述其结构及其上的操作,特别是在利用指针访问顺序存储结构时,传统的分析方法只关注了指针的指向关系,而未讨论指针可能发生偏移的数值信息,且未考虑发生偏移时可能存在越界的不安全问题,导致了对顺序存储结构分析不精确.针对以上不足,首先对顺序存储结构进行抽象建模,并对顺序存储结构与指针结合使用时的指向关系与偏移量进行有效表示,建立了用于顺序存储结构的抽象内存模型SeqMM;其次,归纳总结C程序中顺序存储结构涉及的指针相关迁移操作、谓词操作及遍历顺序存储结构的循环操作,提出了安全范围判别保证操作安全性;之后,针对函数调用时形参指针引用顺序存储结构与实参的映射过程进行过程间推导规则设计;最后,基于上述分析,提出了一种内存泄漏缺陷检测算法对5个开源C工程的内存泄漏缺陷进行检测.实验结果表明:所提出的SeqMM能够有效地刻画C程序中的顺序存储结构及其涉及的各种操作,其数据流分析结果能够用于内存泄漏的检测工作,同时在效率和精度之间取得合理的权衡. 相似文献
18.
19.
Mengda He Viktor Vafeiadis Shengchao Qin João F. Ferreira 《International journal of parallel programming》2018,46(6):1157-1183
In order to support efficient compilation to modern architectures, mainstream programming languages, such as C/C\(++\) and Java, have adopted weak (or relaxed) memory models. According to these weak memory models, multithreaded programs are allowed to exhibit behaviours that would have been inconsistent under the traditional strong (i.e., sequentially consistent) memory model. This makes the task of reasoning about concurrent programs even more challenging. The GPS framework, developed by Turon et al. (ACM OOPSLA, pp 691–707, 2014), has made a step forward towards tackling this challenge for the release–acquire fragment of the C11 memory model. By integrating ghost states, per-location protocols and separation logic, GPS can successfully verify programs with release–acquire atomics. In this paper, we introduced GPS\(+\) to support a larger class of C11 programs, that is, programs with release–acquire atomics, relaxed atomics and release–acquire fences. Key elements of our proposed logic include two new types of assertions, a more expressive resource model and a set of new verification rules. 相似文献