release mode question

hi all my friend . when i want to release my project in multithread mode the compiler take :

Warning 1 warning C4722: 'myClass::~myClass' : destructor never returns, potential memory leak
Can we see the destructor?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class myClass{
public:
	myClass(void);
	~myClass(void);

............

myClass::~myClass(void)
{
	if ( m_hMutex )
		CloseHandle( m_hMutex );

	ExitProcess( 0 );
}
Last edited on
Ah. Okay.

Yeah ExitProcess kills your process before the constructor finishes. So anythign the program would do after the destructor (call parent ctor, free memory, etc) won't be performed, which is why the compiler is giving you that warning.

That said -- you won't really leak memory because even if your program doesn't free the memory, the OS will free up all the memory your program used once it exits.

But do you need to call ExitProcess there? Why can't you just let the program exit normally?
i have several thread in my program just want release them with exitprocess :-??
Topic archived. No new replies allowed.