Click here to Skip to main content
15,906,708 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralPDF Viewer Pin
Mahesh Varma11-Feb-04 2:32
Mahesh Varma11-Feb-04 2:32 
GeneralRe: PDF Viewer Pin
Joel Lucsy11-Feb-04 2:57
Joel Lucsy11-Feb-04 2:57 
GeneralHelp with memory leak warning message Pin
J.B.11-Feb-04 2:15
J.B.11-Feb-04 2:15 
GeneralRe: Help with memory leak warning message Pin
Antti Keskinen11-Feb-04 2:31
Antti Keskinen11-Feb-04 2:31 
GeneralRe: Help with memory leak warning message Pin
J.B.11-Feb-04 5:21
J.B.11-Feb-04 5:21 
GeneralRe: Help with memory leak warning message Pin
Antti Keskinen11-Feb-04 6:34
Antti Keskinen11-Feb-04 6:34 
GeneralRe: Help with memory leak warning message (solved) Pin
J.B.11-Feb-04 17:11
J.B.11-Feb-04 17:11 
GeneralRe: Help with memory leak warning message (solved) Pin
Antti Keskinen11-Feb-04 18:41
Antti Keskinen11-Feb-04 18:41 
I believe that it might be a combination of the status bar and a dialog.

As default, the dialog class is not suited for handling a status bar, so you must override the OnOk handler, and explicitly call 'm_statusbar.DestroyWindow' method to destroy the Windows status bar control upon exit. The dialog class is not aware of the status bar control otherwise than that it is a child control. Upon exit, the class issues a WM_DESTROY for all child controls, but for some reason, the status bar does not handle this properly.

So, call the manual destruction method of the class in the OnOk handler. I think this should remove at least one or two of the memory leaks.

The break problem is because of the multi-threading. Accessing a class directly from across the thread is dangerous, because the memory areas might become corrupted. Instead, add handlers for different messages in your status bar class, and register a set of new Windows messages for your convinience. Messages such as WM_MY_SETTEXT and send the new text string in WPARAM and perhaps the ID in LPARAM. Using Windows messages is a safe way to signal changes across threads.

One last option is to try AFX_MANAGE_STATE( AfxGetStaticModuleState() ); call pair. This function sets the thread/module state until end of it's calling scope. Basically, it ensures that all data within this context's (the thread's) memory block is valid. It works smoothly for DLL's, but I am unsure how it affects multi-threaded applications. It might, or might not, help you. Also, make sure you are linking with the multi-threaded version of the MFC library files. Linking with the single-threaded ones in this case might also be the problem.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralRe: Help with memory leak warning message (solved) Pin
J.B.12-Feb-04 6:04
J.B.12-Feb-04 6:04 
GeneralRe: Help with memory leak warning message Pin
Peter Weyzen11-Feb-04 7:42
Peter Weyzen11-Feb-04 7:42 
GeneralRe: Help with memory leak warning message Pin
Graham Bradshaw11-Feb-04 3:49
Graham Bradshaw11-Feb-04 3:49 
GeneralReading the USB port Pin
Demian Panello11-Feb-04 2:01
Demian Panello11-Feb-04 2:01 
GeneralRe: Reading the USB port Pin
Antti Keskinen11-Feb-04 2:35
Antti Keskinen11-Feb-04 2:35 
GeneralRe: Reading the USB port Pin
Demian Panello11-Feb-04 4:54
Demian Panello11-Feb-04 4:54 
Generaledk.h Pin
barzw11-Feb-04 1:08
barzw11-Feb-04 1:08 
GeneralRe: edk.h Pin
Michael P Butler11-Feb-04 1:18
Michael P Butler11-Feb-04 1:18 
Generalmachine code Pin
Anonymous11-Feb-04 0:53
Anonymous11-Feb-04 0:53 
GeneralRe: machine code Pin
Prakash Nadar11-Feb-04 1:04
Prakash Nadar11-Feb-04 1:04 
GeneralRe: machine code Pin
Anonymous11-Feb-04 1:13
Anonymous11-Feb-04 1:13 
GeneralRe: machine code Pin
jmkhael11-Feb-04 1:30
jmkhael11-Feb-04 1:30 
GeneralRe: machine code Pin
Anonymous11-Feb-04 1:37
Anonymous11-Feb-04 1:37 
GeneralRe: machine code Pin
jhwurmbach11-Feb-04 2:47
jhwurmbach11-Feb-04 2:47 
GeneralRe: machine code Pin
Antti Keskinen11-Feb-04 3:04
Antti Keskinen11-Feb-04 3:04 
GeneralRe: machine code Pin
Prakash Nadar11-Feb-04 1:35
Prakash Nadar11-Feb-04 1:35 
GeneralRe: machine code Pin
Alexander M.,11-Feb-04 5:10
Alexander M.,11-Feb-04 5:10 

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.