Click here to Skip to main content
14,689,978 members
Home » Discussions » ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: narrowing the focus a bit Pin
Richard MacCutchan4-Jul-14 21:10
mveRichard MacCutchan4-Jul-14 21:10 
Generalreasons Pin
bkelly135-Jul-14 8:22
Memberbkelly135-Jul-14 8:22 
GeneralRe: reasons Pin
Richard MacCutchan6-Jul-14 5:44
mveRichard MacCutchan6-Jul-14 5:44 
GeneralRe: reasons Pin
bkelly137-Jul-14 15:03
Memberbkelly137-Jul-14 15:03 
GeneralRe: reasons Pin
Richard MacCutchan7-Jul-14 23:04
mveRichard MacCutchan7-Jul-14 23:04 
Questionfriend declaration causes undeclared identifier Pin
bkelly1330-Jun-14 6:55
Memberbkelly1330-Jun-14 6:55 
AnswerRe: friend declaration causes undeclared identifier Pin
Subrat 470826612-Sep-14 16:20
MemberSubrat 470826612-Sep-14 16:20 
Questiondestructor not being called (Resolved) Pin
bkelly1326-Jun-14 17:17
Memberbkelly1326-Jun-14 17:17 
Windows 7, Visual Studio, C++, MFC dialog
A MFC dialog calls _beginthreadex and starts procedure Start_Server_As_Thread as a new thread.
That procedure instantiates class C_Server_Thread then calls a method that loops until an event indicates time to exit. That class creates a new instance of C_Log_Writer to write information to a log file.
The appropriate event is set, and the main loop exits.
Immediately on regaining control, procedure Start_Server_As_Thread deletes the class with:
delete mp_C_Server_Thread;

The destructor of that class is not called. The destructor contains the code
delete mp_C_Log_Writer;

which does not get run resulting in a memory leak.

I was under the impression that explicitly deleting an instance of a class forced the destructor to be called. What should I do to get that destructor called?
In the code that detects said event I can add a line to delete the logger class. Still, the question will remain, why is the destructor not called?
Edit:
Just for completeness, a silly mistake that I looked right at several times before finally stepping through the code one step at a time.
if( mp_C_Log_Writer == NULL )
  {
      delete mp_C_Log_Writer;
      mp_C_Log_Writer = NULL;


The == should have been !=. Lesson learned again, always step through every line of code with the debugger at least once. Sorry to trouble anyone over this.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com



modified 29-Jun-14 16:55pm.

AnswerRe: destructor not being called Pin
Orjan Westin26-Jun-14 23:26
professionalOrjan Westin26-Jun-14 23:26 
GeneralRe: destructor not being called Pin
bkelly1327-Jun-14 14:06
Memberbkelly1327-Jun-14 14:06 
Questionarray of static text controls Pin
bkelly1322-Jun-14 10:35
Memberbkelly1322-Jun-14 10:35 
AnswerRe: array of static text controls Pin
Albert Holguin26-Jun-14 11:48
professionalAlbert Holguin26-Jun-14 11:48 
Questionneed help selecting a string type Pin
bkelly1313-Jun-14 5:27
Memberbkelly1313-Jun-14 5:27 
AnswerRe: need help selecting a string type Pin
Richard MacCutchan13-Jun-14 8:13
mveRichard MacCutchan13-Jun-14 8:13 
GeneralRe: need help selecting a string type Pin
bkelly1313-Jun-14 8:39
Memberbkelly1313-Jun-14 8:39 
GeneralRe: need help selecting a string type Pin
Richard MacCutchan13-Jun-14 22:31
mveRichard MacCutchan13-Jun-14 22:31 
GeneralRe: need help selecting a string type Pin
bkelly1314-Jun-14 10:47
Memberbkelly1314-Jun-14 10:47 
GeneralRe: need help selecting a string type Pin
Richard MacCutchan14-Jun-14 11:05
mveRichard MacCutchan14-Jun-14 11:05 
GeneralRe: need help selecting a string type Pin
bkelly1314-Jun-14 16:53
Memberbkelly1314-Jun-14 16:53 
GeneralRe: need help selecting a string type Pin
Richard MacCutchan14-Jun-14 22:08
mveRichard MacCutchan14-Jun-14 22:08 
Generalgoing heavy Pin
bkelly1316-Jun-14 14:49
Memberbkelly1316-Jun-14 14:49 
GeneralRe: going heavy Pin
Richard MacCutchan16-Jun-14 22:24
mveRichard MacCutchan16-Jun-14 22:24 
GeneralRe: need help selecting a string type Pin
Theo Buys6-Aug-15 6:31
MemberTheo Buys6-Aug-15 6:31 
QuestionEnd a socket listen() operation Pin
bkelly133-Jun-14 9:26
Memberbkelly133-Jun-14 9:26 
AnswerRe: End a socket listen() operation Pin
Albert Holguin5-Jun-14 10:41
professionalAlbert Holguin5-Jun-14 10:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.