c++ - Memory leak when using std::list -


how remove memory leak std::list?

this example code :

#define _crtdbg_map_alloc #include <stdlib.h> #include <crtdbg.h>  #include <iostream> #include <list> using namespace std;  void main() {     list<int> a;     a.clear();     _crtdumpmemoryleaks(); } 

when try run it, shows memory leak.

so, how remove it?

there no memory leak. report telling memory has not yet been deallocated, true. deallocated @ end of current scope - after _crtdumpmemoryleaks() has run.

alter code follows; provide more accurate answer:

void main() {     {         list<int> a;         a.clear();     }     _crtdumpmemoryleaks(); } 

note movement of a container own scope.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -