Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Visual Leak Detector (VLD) to improve code quality / 利用VLD检查代码内存泄漏 #9

Open
crazyzlj opened this issue Mar 27, 2017 · 0 comments
Assignees
Labels

Comments

@crazyzlj
Copy link
Contributor

crazyzlj commented Mar 27, 2017

利用Visual Leak Detector (VLD) 2.5.1 检查了模型框架代码的内存泄漏问题

代码更改详见pull7

其实说白了内存泄漏就是没有把new和delete配对使用,但是实际编码中,尤其是涉及复杂类与类之间相互调用的时候,理清什么时候释放哪块内存是不太容易的。

我这次主要检查了数组、含有自定义数据类型(或类实例)的容器(vector,map等)以及复杂类的释放及析构函数,这些可能涵盖了我们日常编程常见的内存泄漏问题。

对于复杂类的编写,大家要遵循“Rules of three”原则,即如果你的类需要以下任意一个函数,那么就请显式写出所有三个:

  • 复制构造函数(Copy Constructor)
  • 赋值操作符(Assignment Operator)
  • 析构函数(Destructor)

这里扩展阅读

当然,代码依然存在潜在问题,大家在扩充模块的同时,也可以多多关注框架的bug,并修复。

@crazyzlj crazyzlj self-assigned this Mar 31, 2017
@crazyzlj crazyzlj changed the title using Visual Leak Detector (VLD) to improve your code quality [Protocol] Using Visual Leak Detector (VLD) to improve code quality Mar 31, 2017
@crazyzlj crazyzlj changed the title [Protocol] Using Visual Leak Detector (VLD) to improve code quality [Protocol] Using Visual Leak Detector (VLD) to improve code quality / 利用VLD检查代码内存泄漏 Mar 31, 2017
@crazyzlj crazyzlj changed the title [Protocol] Using Visual Leak Detector (VLD) to improve code quality / 利用VLD检查代码内存泄漏 Using Visual Leak Detector (VLD) to improve code quality / 利用VLD检查代码内存泄漏 Mar 31, 2017
crazyzlj added a commit that referenced this issue Aug 15, 2023
13444638 Merge pull request #9 from crazyzlj/dev
c78b3437 (bugfix):set installation related paths to cache

git-subtree-dir: seims/src/ccgl
git-subtree-split: 134446389c1c51c8cfd2d063e119663e0c72e8da
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant