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. Detected memory leaks! :(

Detected memory leaks! :(

Scheduled Pinned Locked Moved C / C++ / MFC
c++debuggingperformancehelpquestion
5 Posts 2 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.
  • L Offline
    L Offline
    lucy 0
    wrote on last edited by
    #1

    help me please, I am stucked here. :mad: It's a very simple SDI application. I got it from MFC appWizard. In the view class, I started a worker thread, which will be running until a flag is cleared. I made sure that the worker thread is ended before the program terminate, because I put a TRACE line before its return statement, and the line is outputed. But still, I got such info: Detected memory leaks! Dumping objects -> thrdcore.cpp(166) : {97} client block at 0x00305BB0, subtype 0, 112 bytes long. a CWinThread object at $00305BB0, 112 bytes long Object dump complete. To make it more annoying, this doesn't happen all the time. What can go wrong? :confused::confused::confused: Any clue is appreciated!

    R 1 Reply Last reply
    0
    • L lucy 0

      help me please, I am stucked here. :mad: It's a very simple SDI application. I got it from MFC appWizard. In the view class, I started a worker thread, which will be running until a flag is cleared. I made sure that the worker thread is ended before the program terminate, because I put a TRACE line before its return statement, and the line is outputed. But still, I got such info: Detected memory leaks! Dumping objects -> thrdcore.cpp(166) : {97} client block at 0x00305BB0, subtype 0, 112 bytes long. a CWinThread object at $00305BB0, 112 bytes long Object dump complete. To make it more annoying, this doesn't happen all the time. What can go wrong? :confused::confused::confused: Any clue is appreciated!

      R Offline
      R Offline
      Roger Allen
      wrote on last edited by
      #2

      As its a CWinThread object thats been leaked, you can either store the pointer when you create the thread or set the m_bAutoDelete member var to true so it deletes itself when the thread ends. Roger Allen Sonork 100.10016 In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!

      L 3 Replies Last reply
      0
      • R Roger Allen

        As its a CWinThread object thats been leaked, you can either store the pointer when you create the thread or set the m_bAutoDelete member var to true so it deletes itself when the thread ends. Roger Allen Sonork 100.10016 In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!

        L Offline
        L Offline
        lucy 0
        wrote on last edited by
        #3

        Thank you for your quick help. I set it, but it didn't solve the problem. anything else?:confused::confused:

        1 Reply Last reply
        0
        • R Roger Allen

          As its a CWinThread object thats been leaked, you can either store the pointer when you create the thread or set the m_bAutoDelete member var to true so it deletes itself when the thread ends. Roger Allen Sonork 100.10016 In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!

          L Offline
          L Offline
          lucy 0
          wrote on last edited by
          #4

          I noticed that after I rebuild the project then run it for the first time, this memory leak will occur for sure. The subsequent running doesn't have this problem. Why this inconsistence?:confused:

          1 Reply Last reply
          0
          • R Roger Allen

            As its a CWinThread object thats been leaked, you can either store the pointer when you create the thread or set the m_bAutoDelete member var to true so it deletes itself when the thread ends. Roger Allen Sonork 100.10016 In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!

            L Offline
            L Offline
            lucy 0
            wrote on last edited by
            #5

            It seemed that after I add #include "StdAfx.h" to my generic cpp file, this problem is solved. But in my generic cpp file, all I did is some mathematical computation. No input or output involved, except for the argument passing to the function. What does StdAfx.h do here? Why I have to include it? It makes no sense to me. X|

            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