cplusplus.com
C++ : Forum : Windows Programming : Win32 API Memory Leak
 
cplusplus.com
Information
Documentation
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs


post Win32 API Memory Leak

Lamblion (627)
I have an application with four main tabs. I am encountering a 4k memory leak on about every sixth to eighth tab change. Not much, I know, but it's bugging me. The ONLY place I can figure the leak is in the following code, although I can't for the life of me see how the following code could be causing the leak. Is this code leaking memory...

1
2
3
4
5
6
7
if(NULL != hAccel)
	{
		DestroyAcceleratorTable(hAccel);
		hAccel=NULL;
	}

	hAccel = LoadAccelerators(hBOSSInst, MAKEINTRESOURCE(IDR_VLO_ACCEL));


Or are there some memory gremlins lurking about that I can't see?
Grey Wolf (2846)
You should check the return from DestroyAcceleratorTable() before nulling hAccel.
It will return nonzero if it succeeds and zero on failure. It will fail if CreateAcceleratorTable or LoadAccelerators function are called more than once.
Lamblion (627)
Good idea. I'll do that.
Topic archived. No new replies allowed.