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. Huge increase in memory usage with Debug binary [modified]

Huge increase in memory usage with Debug binary [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
debuggingperformancequestionannouncement
8 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.
  • M Offline
    M Offline
    mandanani
    wrote on last edited by
    #1

    Hi All, I added virtual copy constructor for quite a few classes. I see a drastic difference in memory usage before and after the change, that too only with debug binary. When I ran release binary the memory usage is almost the same. Here below are the memory statistics Before Change ------------- Peak Mem Usage & VM Size for Debug binary is: 15 MB & 10.5 MB Peak Mem Usage & VM Size for Release binary is: 11.5 MB & 8 MB After Change ------------- Peak Mem Usage & VM Size for Debug binary is: 29 MB & 26 MB Peak Mem Usage & VM Size for Release binary is: 12 MB & 8.5 MB Is it the case virtual copy constructor makes debug binary use more space? Thanks and Regards, Nani -- modified at 4:39 Wednesday 6th June, 2007

    D C M 3 Replies Last reply
    0
    • M mandanani

      Hi All, I added virtual copy constructor for quite a few classes. I see a drastic difference in memory usage before and after the change, that too only with debug binary. When I ran release binary the memory usage is almost the same. Here below are the memory statistics Before Change ------------- Peak Mem Usage & VM Size for Debug binary is: 15 MB & 10.5 MB Peak Mem Usage & VM Size for Release binary is: 11.5 MB & 8 MB After Change ------------- Peak Mem Usage & VM Size for Debug binary is: 29 MB & 26 MB Peak Mem Usage & VM Size for Release binary is: 12 MB & 8.5 MB Is it the case virtual copy constructor makes debug binary use more space? Thanks and Regards, Nani -- modified at 4:39 Wednesday 6th June, 2007

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      mandanani wrote:

      I added virtual copy constructor...

      How?


      "A good athlete is the result of a good and worthy opponent." - David Crow

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      M 1 Reply Last reply
      0
      • M mandanani

        Hi All, I added virtual copy constructor for quite a few classes. I see a drastic difference in memory usage before and after the change, that too only with debug binary. When I ran release binary the memory usage is almost the same. Here below are the memory statistics Before Change ------------- Peak Mem Usage & VM Size for Debug binary is: 15 MB & 10.5 MB Peak Mem Usage & VM Size for Release binary is: 11.5 MB & 8 MB After Change ------------- Peak Mem Usage & VM Size for Debug binary is: 29 MB & 26 MB Peak Mem Usage & VM Size for Release binary is: 12 MB & 8.5 MB Is it the case virtual copy constructor makes debug binary use more space? Thanks and Regards, Nani -- modified at 4:39 Wednesday 6th June, 2007

        C Offline
        C Offline
        Cyrilix
        wrote on last edited by
        #3

        I thought constructors couldn't be virtual, since they require complete information to create the object.

        D 1 Reply Last reply
        0
        • C Cyrilix

          I thought constructors couldn't be virtual, since they require complete information to create the object.

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Cyrilix wrote:

          I thought constructors couldn't be virtual, since they require complete information to create the object.

          You are correct, hence my question to him as to how he managed to pull this off.


          "A good athlete is the result of a good and worthy opponent." - David Crow

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          M 1 Reply Last reply
          0
          • M mandanani

            Hi All, I added virtual copy constructor for quite a few classes. I see a drastic difference in memory usage before and after the change, that too only with debug binary. When I ran release binary the memory usage is almost the same. Here below are the memory statistics Before Change ------------- Peak Mem Usage & VM Size for Debug binary is: 15 MB & 10.5 MB Peak Mem Usage & VM Size for Release binary is: 11.5 MB & 8 MB After Change ------------- Peak Mem Usage & VM Size for Debug binary is: 29 MB & 26 MB Peak Mem Usage & VM Size for Release binary is: 12 MB & 8.5 MB Is it the case virtual copy constructor makes debug binary use more space? Thanks and Regards, Nani -- modified at 4:39 Wednesday 6th June, 2007

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            Besides the question that needs an answer (what the heck is a virtual copy constructor???) the memory usage increase was hardly "drastic". Is there a reason you're worried about how much memory (even if you could get an accurate measurement of it) your app is using in a debug configuration? Mark

            "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

            M 1 Reply Last reply
            0
            • D David Crow

              mandanani wrote:

              I added virtual copy constructor...

              How?


              "A good athlete is the result of a good and worthy opponent." - David Crow

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              M Offline
              M Offline
              mandanani
              wrote on last edited by
              #6

              You mean in what way I added virtual copy constructor? Here below is the code: CValueObjectBase* CashflowVO::clone() const { return new CashflowVO(*this); } Here CValueObjectBase is base class and clone method is pure virtual method. The clone method of derived class copies the object and return base class pointer. Hope I have provided the right information.

              1 Reply Last reply
              0
              • M Mark Salsbery

                Besides the question that needs an answer (what the heck is a virtual copy constructor???) the memory usage increase was hardly "drastic". Is there a reason you're worried about how much memory (even if you could get an accurate measurement of it) your app is using in a debug configuration? Mark

                "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder

                M Offline
                M Offline
                mandanani
                wrote on last edited by
                #7

                Yes. The statistics I provided here are for sample data. When I ran my applicaiton with full production data the debug binary consumes 1.5 GB of virtual memory. Before the change the debug binary used to consume around 700 MB memory. There is not much difference in memory usage with release binary before and after the change. I want to know whether virtual copy constructor adds more symbols to debug binary. Thanks, Nani

                1 Reply Last reply
                0
                • D David Crow

                  Cyrilix wrote:

                  I thought constructors couldn't be virtual, since they require complete information to create the object.

                  You are correct, hence my question to him as to how he managed to pull this off.


                  "A good athlete is the result of a good and worthy opponent." - David Crow

                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                  M Offline
                  M Offline
                  mandanani
                  wrote on last edited by
                  #8

                  Actually, this is a method which does the job of constructor. Here below is the code snippet: class CashflowVO derived from CValueObjectBase >>>>>>>>>>>>>>>>>>>> CValueObjectBase* CashflowVO::clone() const { return new CashflowVO(*this); } >>>>>>>>>>>>>>>>>>>> Clone methos is pure virtual method in CValueObjectBase. The below code calls the respective clone method of derived object. Here pValueObjectBaseOrg can be any of the derived class, but respective object is getting copied and pointer is returned to pValueObjectBase. >>>>>>>>>>>>>>>>>>>> CValueObjectBase * m_pValueObjectBase = m_pValueObjectBaseOrg->clone(); >>>>>>>>>>>>>>>>>>>> Hope I make sense here.

                  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