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. Cleaning my memory wenn shutting down programm

Cleaning my memory wenn shutting down programm

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++databasedata-structuresperformance
6 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.
  • W Offline
    W Offline
    Willem B
    wrote on last edited by
    #1

    hi, I'm developing a program that uses linked list's as a cover for the database. So i have list's of >1000 struct's. wenn i shut down my program i get memory dumps: C:\projecten\PLCServer 0.2\DBVoorraadBeheer.cpp(63) : {3263} normal block at 0x06B95498, 44 bytes long. Data: < dU U U > 01 00 00 00 64 55 B9 06 0C 55 B9 06 BC 55 B9 06 strcore.cpp(118) : {3262} normal block at 0x06B95440, 15 bytes long. Data: < A > 01 00 00 00 01 00 00 00 02 00 00 00 41 00 00 strcore.cpp(118) : {3261} normal block at 0x06B953B8, 67 bytes long. Data: < 6 Spir> 01 00 00 00 1B 00 00 00 36 00 00 00 53 70 69 72 strcore.cpp(118) : {3260} normal block at 0x06B95360, 25 bytes long. Data: < 0700> 01 00 00 00 06 00 00 00 0C 00 00 00 30 37 30 30 strcore.cpp(118) : {3259} normal block at 0x06B95308, 25 bytes long. Data: < Cool> 01 00 00 00 06 00 00 00 0C 00 00 00 43 6F 6F 6C how can i prevent this? []D [] []D []

    C 1 Reply Last reply
    0
    • W Willem B

      hi, I'm developing a program that uses linked list's as a cover for the database. So i have list's of >1000 struct's. wenn i shut down my program i get memory dumps: C:\projecten\PLCServer 0.2\DBVoorraadBeheer.cpp(63) : {3263} normal block at 0x06B95498, 44 bytes long. Data: < dU U U > 01 00 00 00 64 55 B9 06 0C 55 B9 06 BC 55 B9 06 strcore.cpp(118) : {3262} normal block at 0x06B95440, 15 bytes long. Data: < A > 01 00 00 00 01 00 00 00 02 00 00 00 41 00 00 strcore.cpp(118) : {3261} normal block at 0x06B953B8, 67 bytes long. Data: < 6 Spir> 01 00 00 00 1B 00 00 00 36 00 00 00 53 70 69 72 strcore.cpp(118) : {3260} normal block at 0x06B95360, 25 bytes long. Data: < 0700> 01 00 00 00 06 00 00 00 0C 00 00 00 30 37 30 30 strcore.cpp(118) : {3259} normal block at 0x06B95308, 25 bytes long. Data: < Cool> 01 00 00 00 06 00 00 00 0C 00 00 00 43 6F 6F 6C how can i prevent this? []D [] []D []

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      Willem B wrote: how can i prevent this? delete all objects/memory that you allocate with 'new' and free all memory you allocate with 'malloc'. -c


      Image tools: ThumbNailer, Bobber, TIFFAssembler

      W 1 Reply Last reply
      0
      • C Chris Losinger

        Willem B wrote: how can i prevent this? delete all objects/memory that you allocate with 'new' and free all memory you allocate with 'malloc'. -c


        Image tools: ThumbNailer, Bobber, TIFFAssembler

        W Offline
        W Offline
        Willem B
        wrote on last edited by
        #3

        is it harmfull if i let the compiler delete it? []D [] []D []

        C A A 3 Replies Last reply
        0
        • W Willem B

          is it harmfull if i let the compiler delete it? []D [] []D []

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #4

          if you don't delete it, your program will leak memory. -c


          Image tools: ThumbNailer, Bobber, TIFFAssembler

          1 Reply Last reply
          0
          • W Willem B

            is it harmfull if i let the compiler delete it? []D [] []D []

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            Willem B wrote: is it harmfull if i let the compiler delete it? It just won't do it: You told him that you wanted memory (new), got it (new succeeded), and now you have to tell him that you dont want it anymore (delete). If you want it automatic, then don't new your variables!

            1 Reply Last reply
            0
            • W Willem B

              is it harmfull if i let the compiler delete it? []D [] []D []

              A Offline
              A Offline
              Alvaro Mendez
              wrote on last edited by
              #6

              Anything allocated with new or malloc is not "deleted" by the compiler. It needs to be cleaned up with "delete", "free", or you can just let it happen when the program exits. However, if the program runs for a while, more and more memory may continue to be allocated and eventually you'll run out of it, causing the program to crash. The only memory the compiler cleans up automatically is the stack, which you can use to efficiently allocate any variable:

              {
              CString s = "allocated on the stack so it will be free automatically";
              CString* p = new CString("allocated on the heap, needs to be freed with delete");

              delete p; // p must be cleaned up explicitly
              } // s is automatically cleaned up here

              Regards, Alvaro


              When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com

              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