Sign in to follow this  

[C++]Check memory leak with Task Manangement

Recommended Posts

Hi, I proccess the following program and I commented the program size (in KB) given by the Windows Task Management. I was wondering why a such behaviour in C++, it looks like to be a Java behaviour with his Garbage Collector. Any answer will be appreciated it.
       char *a, *b, *c, *d, *e, f;

	cin>>f; //284 KO

	a = new char[2048];
	b = new char[2048];
	c = new char[2048];
	d = new char[2048];
	e = new char[2048];

	cin>>f; // 296 KO

	delete[] a;
	delete[] b;
	delete[] c;
	delete[] d;
	delete[] e;

	cin>>f; // 296 KO

Share this post

Link to post
Share on other sites
The Task Manager doesn't give the complete picture. It is not a reliable source.

C++ isn't garbage collected. More likely that some component (such as the allocator in the runtime, or perhaps the OS) is caching that memory, anticipating that you will request more. This is quite normal.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this