Click here to Skip to main content
15,885,767 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Bluetooth - COM port reading Pin
tnt00018-Jan-11 5:27
tnt00018-Jan-11 5:27 
GeneralRe: Bluetooth - COM port reading Pin
Andrew Brock18-Jan-11 14:07
Andrew Brock18-Jan-11 14:07 
QuestionDifference between _stat() and _fstat() Pin
gomathylakshmanan17-Jan-11 19:47
gomathylakshmanan17-Jan-11 19:47 
AnswerRe: Difference between _stat() and _fstat() Pin
Andrew Brock17-Jan-11 19:53
Andrew Brock17-Jan-11 19:53 
QuestionCTypedPtrArray & CStringArray Pin
mesajflaviu17-Jan-11 9:10
mesajflaviu17-Jan-11 9:10 
AnswerRe: CTypedPtrArray & CStringArray Pin
Chris Meech17-Jan-11 10:01
Chris Meech17-Jan-11 10:01 
GeneralRe: CTypedPtrArray & CStringArray Pin
mesajflaviu17-Jan-11 19:06
mesajflaviu17-Jan-11 19:06 
AnswerRe: CTypedPtrArray & CStringArray Pin
Andrew Brock17-Jan-11 16:04
Andrew Brock17-Jan-11 16:04 
Firstly, make sure you are dumping the memory leaks correctly. There are a number of ways to do this, but the best is by adding
#if defined(DEBUG) || defined(_DEBUG)
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif

as early in your code as possible, in your case it will be the constructor of your App object BOOL CxxxApp::CxxxApp()
This is the only way will dump the memory leaks after all static objects have been destroyed. All other ways that I know of will give misleading results if you have static objects

If no destructor is provided for your class 1 is generated which calls the destructors of all member classes, otherwise the destructors of all member classes is called after your destructor code.
In destructors you only need to delete memory allocated by new, malloc or the likes.

Either way, your code is calling the destructors to m_saTable and m_saTables and these destructors will free any memory associated with it.

Having said that, your CTableArray is storing pointers, which means that the destructor for the table will only free the pointers, and not the actual data.
You will need to enumerate each item and free its memory manually. CMyDoc::OnCloseDocument() would be a good place to do this.
INT_PTR nElements = m_saTables.GetCount();
for (int nIndex = 0; nIndex < nElements; ++nIndex) {
	delete m_saTables.GetAt(nIndex); //assuming the elements inserted were created with "new CStringArray"
}

GeneralRe: CTypedPtrArray & CStringArray Pin
mesajflaviu17-Jan-11 19:38
mesajflaviu17-Jan-11 19:38 
GeneralRe: CTypedPtrArray & CStringArray Pin
Andrew Brock17-Jan-11 19:51
Andrew Brock17-Jan-11 19:51 
AnswerRe: CTypedPtrArray & CStringArray Pin
mesajflaviu17-Jan-11 22:11
mesajflaviu17-Jan-11 22:11 
GeneralRe: CTypedPtrArray & CStringArray Pin
Andrew Brock17-Jan-11 22:36
Andrew Brock17-Jan-11 22:36 
GeneralRe: CTypedPtrArray & CStringArray Pin
mesajflaviu18-Jan-11 1:47
mesajflaviu18-Jan-11 1:47 
QuestionDisplay dialog after SDI app opens Pin
David Crow17-Jan-11 3:01
David Crow17-Jan-11 3:01 
AnswerRe: Display dialog after SDI app opens Pin
Maximilien17-Jan-11 3:30
Maximilien17-Jan-11 3:30 
GeneralRe: Display dialog after SDI app opens Pin
David Crow17-Jan-11 3:39
David Crow17-Jan-11 3:39 
AnswerRe: Display dialog after SDI app opens Pin
Andrew Brock17-Jan-11 3:54
Andrew Brock17-Jan-11 3:54 
AnswerRe: Display dialog after SDI app opens Pin
David Crow17-Jan-11 8:36
David Crow17-Jan-11 8:36 
AnswerRe: Display dialog after SDI app opens Pin
Alain Rist17-Jan-11 5:48
Alain Rist17-Jan-11 5:48 
AnswerRe: Display dialog after SDI app opens Pin
PJ Arends17-Jan-11 7:51
professionalPJ Arends17-Jan-11 7:51 
QuestionImplementation of Chord DHT in ANSI C. Pin
przemnet17-Jan-11 1:42
przemnet17-Jan-11 1:42 
GeneralRe: Implementation of Chord DHT in ANSI C. Pin
CPallini17-Jan-11 2:01
mveCPallini17-Jan-11 2:01 
QuestionQuestion for Static control with Notify property. Pin
Le@rner16-Jan-11 22:43
Le@rner16-Jan-11 22:43 
AnswerRe: Question for Static control with Notify property. Pin
Niklas L16-Jan-11 22:50
Niklas L16-Jan-11 22:50 
GeneralRe: Question for Static control with Notify property. Pin
Le@rner16-Jan-11 23:10
Le@rner16-Jan-11 23: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.