TRY THIS AND YOU GET A MEMORY LEAK ??? 
Author Message
 TRY THIS AND YOU GET A MEMORY LEAK ???

Hello,

Try this :

    1. Build an MFCApp using AppWizard in Visual Studio (6.0) (accept all
defaults)
    2. Map message WM_CHAR in the View
    3. Implement as follows :

        void CMFCTestView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
        {
             switch (nChar)
             {
                  case 27 : PostQuitMessage(0);
                                 return ;
             }
             CView::OnChar(nChar, nRepCnt, nFlags);
        }

    4. Build and Run
    5. Press escape (quits the application)
    6. Watch the memory dump in the output window

    Is this to be expected or is there another way to quit an application
without having
    this annoying memory leak ??

Thanks.

Chris



Wed, 14 Nov 2001 03:00:00 GMT  
 TRY THIS AND YOU GET A MEMORY LEAK ???

Hi,
By sending a Quitmessage you dump the programm totally
without giving yourself any chance of cleanup. This is definitely the wrong way of terminating a program.

You should post either a WM_CLOSE message.

Quote:

>Hello,

>Try this :

>    1. Build an MFCApp using AppWizard in Visual Studio (6.0) (accept all
>defaults)
>    2. Map message WM_CHAR in the View
>    3. Implement as follows :

>        void CMFCTestView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
>        {
>             switch (nChar)
>             {
>                  case 27 : PostQuitMessage(0);
>                                 return ;
>             }
>             CView::OnChar(nChar, nRepCnt, nFlags);
>        }

>    4. Build and Run
>    5. Press escape (quits the application)
>    6. Watch the memory dump in the output window

>    Is this to be expected or is there another way to quit an application
>without having
>    this annoying memory leak ??

>Thanks.

>Chris

-----------------** -- Posted from CodeGuru -- **-----------------
http://www.codeguru.com/    The website for Visual C++ programmers.


Wed, 14 Nov 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. help w/ atl server / vb client getting resulting in memory leak

2. Getting the source from a page gives memory leak

3. Getting crazy with ListBox Data Items memory leaks

4. Handle leak, memory leak...

5. Class object, returning pointers, dynamic memory, memory leaks

6. Finding memory leaks in shared memory pool

7. Memory leaks, DLL and memory allocation.

8. Tracking memory leaks and debugging memory problems

9. Memory leak when using Memory DC

10. Newbie getting runtime Exception (STATUS_ACCESS_VIOLATION) trying to implement Ex. 2-4 from K&R2

11. Newbie getting runtime Exception (STATUS_ACCESS_VIOLATION) trying to implement Ex. 2-4 from K&R2

12. Getting error when SCM tries to start an automatic service

 

 
Powered by phpBB® Forum Software