没有动态内存的内存泄漏 [英] Memory Leak with no dynamic memory
本文介绍了没有动态内存的内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道您是否可能在没有分配任何动态内存的情况下在堆上发生内存泄漏.但是,我确实声明和初始化了三个向量.是因为我需要在关闭程序之前重新分配向量.
I was wondering if you you could have a memory leak on the heap without having any dynamic memory allocated. However, I do have three vectors declared and initialized. Is it because I need to deallocate the vector before I close the program.
推荐答案
我刚刚发现了问题,这是我用来关闭程序的退出函数.
I just found the problem, it was the exit function that I was using to close the program.
exit不会调用任何基于堆栈的对象的析构函数,因此,如果这些对象在内部分配了任何内存,那么内存将被泄漏.
exit does not call the destructors of any stack based objects so if those objects have allocated any memory internally then yes that memory will be leaked.
https://stackoverflow.com/a/7414211/6284032
这篇关于没有动态内存的内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文