Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Memory leak during termination of thread

Memory leak during termination of thread

Scheduled Pinned Locked Moved C / C++ / MFC
c++performancehelp
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shashankacharya
    wrote on last edited by
    #1

    Helllo everybody plz help me ... I started one thread in my application in mfc but on close of my view I got memory leak {367668} normal block at 0x021D82F0, 102 bytes long. Data: < C|& * > B8 AE 43 7C 26 00 00 00 2A 00 00 00 01 00 00 00 {367666} normal block at 0x121BA1E0, 102 bytes long. Data: < C| * > B8 AE 43 7C 1F 00 00 00 2A 00 00 00 01 00 00 00 {342539} normal block at 0x02219868, 118 bytes long. Data: <D : \ MyApp > 44 00 3A 00 5C 00 51 00 50 00 6C 00 75 00 73 00 {254649} normal block at 0x1216AA18, 70 bytes long. Data: < C| > B8 AE 43 7C 1A 00 00 00 1A 00 00 00 01 00 00 00 {188285} normal block at 0x02259E90, 70 bytes long. Data: < C| > B8 AE 43 7C 1A 00 00 00 1A 00 00 00 01 00 00 00 Object dump complete. This errors got. please help me In on close methode SetEvent(m_hKillThread); ::TerminateThread (m_Thread->m_hThread,1); WaitForSingleObject (m_Thread->m_hThread,INFINITE); m_Thread->Delete (); CloseHandle (m_hKillThread); Plz help me:confused::confused:

    C H 2 Replies Last reply
    0
    • S shashankacharya

      Helllo everybody plz help me ... I started one thread in my application in mfc but on close of my view I got memory leak {367668} normal block at 0x021D82F0, 102 bytes long. Data: < C|& * > B8 AE 43 7C 26 00 00 00 2A 00 00 00 01 00 00 00 {367666} normal block at 0x121BA1E0, 102 bytes long. Data: < C| * > B8 AE 43 7C 1F 00 00 00 2A 00 00 00 01 00 00 00 {342539} normal block at 0x02219868, 118 bytes long. Data: <D : \ MyApp > 44 00 3A 00 5C 00 51 00 50 00 6C 00 75 00 73 00 {254649} normal block at 0x1216AA18, 70 bytes long. Data: < C| > B8 AE 43 7C 1A 00 00 00 1A 00 00 00 01 00 00 00 {188285} normal block at 0x02259E90, 70 bytes long. Data: < C| > B8 AE 43 7C 1A 00 00 00 1A 00 00 00 01 00 00 00 Object dump complete. This errors got. please help me In on close methode SetEvent(m_hKillThread); ::TerminateThread (m_Thread->m_hThread,1); WaitForSingleObject (m_Thread->m_hThread,INFINITE); m_Thread->Delete (); CloseHandle (m_hKillThread); Plz help me:confused::confused:

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      shashankacharya wrote:

      ::TerminateThread (m_Thread->m_hThread,1);

      Never use TerminateThread, this is a very bad approach. I suggest you read this article[^] from which you will learn a lot for threads. This is a long article but it's definitively worth reading it.

      Cédric Moonen Software developer
      Charting control [v3.0] OpenGL game tutorial in C++

      S 1 Reply Last reply
      0
      • S shashankacharya

        Helllo everybody plz help me ... I started one thread in my application in mfc but on close of my view I got memory leak {367668} normal block at 0x021D82F0, 102 bytes long. Data: < C|& * > B8 AE 43 7C 26 00 00 00 2A 00 00 00 01 00 00 00 {367666} normal block at 0x121BA1E0, 102 bytes long. Data: < C| * > B8 AE 43 7C 1F 00 00 00 2A 00 00 00 01 00 00 00 {342539} normal block at 0x02219868, 118 bytes long. Data: <D : \ MyApp > 44 00 3A 00 5C 00 51 00 50 00 6C 00 75 00 73 00 {254649} normal block at 0x1216AA18, 70 bytes long. Data: < C| > B8 AE 43 7C 1A 00 00 00 1A 00 00 00 01 00 00 00 {188285} normal block at 0x02259E90, 70 bytes long. Data: < C| > B8 AE 43 7C 1A 00 00 00 1A 00 00 00 01 00 00 00 Object dump complete. This errors got. please help me In on close methode SetEvent(m_hKillThread); ::TerminateThread (m_Thread->m_hThread,1); WaitForSingleObject (m_Thread->m_hThread,INFINITE); m_Thread->Delete (); CloseHandle (m_hKillThread); Plz help me:confused::confused:

        H Offline
        H Offline
        heliboy
        wrote on last edited by
        #3

        First, do not use TerminateThread() to forcely terminate thread. The best way is let the thread terminate itself. If you want to terminate thread while thread is running, set a flag to notify the thread and let it self-terminate. Read the book "Multithreading Applications in Win32", a good book you need to read before you use multithread. Second, you need to check your code to see where you dynamic created variable but not delete it upon thread exit. You need to check this yourself, no other people can help you.

        S 1 Reply Last reply
        0
        • C Cedric Moonen

          shashankacharya wrote:

          ::TerminateThread (m_Thread->m_hThread,1);

          Never use TerminateThread, this is a very bad approach. I suggest you read this article[^] from which you will learn a lot for threads. This is a long article but it's definitively worth reading it.

          Cédric Moonen Software developer
          Charting control [v3.0] OpenGL game tutorial in C++

          S Offline
          S Offline
          shashankacharya
          wrote on last edited by
          #4

          Thanx Cedric Before using terminatethread, I used same logic which given into link but at that time I got run time exception on delete Cwin thread.. is there having another way to remove memory leak.... Can vld find out memory leak which occures due to thread termination. Thank You For your reply...

          1 Reply Last reply
          0
          • H heliboy

            First, do not use TerminateThread() to forcely terminate thread. The best way is let the thread terminate itself. If you want to terminate thread while thread is running, set a flag to notify the thread and let it self-terminate. Read the book "Multithreading Applications in Win32", a good book you need to read before you use multithread. Second, you need to check your code to see where you dynamic created variable but not delete it upon thread exit. You need to check this yourself, no other people can help you.

            S Offline
            S Offline
            shashankacharya
            wrote on last edited by
            #5

            Thanx for your reply... I will read that book. And in my thread I just used local Variable, mydoc variable and my view variables...

            A 1 Reply Last reply
            0
            • S shashankacharya

              Thanx for your reply... I will read that book. And in my thread I just used local Variable, mydoc variable and my view variables...

              A Offline
              A Offline
              Albert Holguin
              wrote on last edited by
              #6

              even if you use local variables you'll end up with memory leaks if the thread is not properly shutdown... good luck! :)

              S 1 Reply Last reply
              0
              • A Albert Holguin

                even if you use local variables you'll end up with memory leaks if the thread is not properly shutdown... good luck! :)

                S Offline
                S Offline
                shashankacharya
                wrote on last edited by
                #7

                thanx albert

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups