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. how to find out the codes who eat up my memory?

how to find out the codes who eat up my memory?

Scheduled Pinned Locked Moved C / C++ / MFC
helpperformancetutorialquestion
10 Posts 7 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.
  • F Offline
    F Offline
    Falconapollo
    wrote on last edited by
    #1

    i have a appilcation consists of thousands lines of code. when i do some specific operation, i.e. open a very large document, the app almost eats up my memory. but after a while, the memory is given back. i have tested the codes and found no memory leak. so, my problem is how to find the codes who eat up my memory. any one can help me?

    L D A J V 6 Replies Last reply
    0
    • F Falconapollo

      i have a appilcation consists of thousands lines of code. when i do some specific operation, i.e. open a very large document, the app almost eats up my memory. but after a while, the memory is given back. i have tested the codes and found no memory leak. so, my problem is how to find the codes who eat up my memory. any one can help me?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Apart from debugging, adding logging to your application or running some code analyzer[^] there is no answer.

      One of these days I'm going to think of a really clever signature.

      1 Reply Last reply
      0
      • F Falconapollo

        i have a appilcation consists of thousands lines of code. when i do some specific operation, i.e. open a very large document, the app almost eats up my memory. but after a while, the memory is given back. i have tested the codes and found no memory leak. so, my problem is how to find the codes who eat up my memory. any one can help me?

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

        Falconapollo wrote:

        so, my problem is how to find the codes who eat up my memory.

        Are you using the new operator?

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

        F 1 Reply Last reply
        0
        • D David Crow

          Falconapollo wrote:

          so, my problem is how to find the codes who eat up my memory.

          Are you using the new operator?

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

          F Offline
          F Offline
          Falconapollo
          wrote on last edited by
          #4

          yes. but there is no memory leak in my codes as i wrote in my post.

          D 1 Reply Last reply
          0
          • F Falconapollo

            yes. but there is no memory leak in my codes as i wrote in my post.

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

            Are you allocating memory to hold the "very large document?"

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

            F 1 Reply Last reply
            0
            • D David Crow

              Are you allocating memory to hold the "very large document?"

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

              F Offline
              F Offline
              Falconapollo
              wrote on last edited by
              #6

              i'm not sure. since the codes are huge. i have no idea to find out the problematic codes. so, what's your recommendations? i think there are some existing tools to do that. do you know some?

              1 Reply Last reply
              0
              • F Falconapollo

                i have a appilcation consists of thousands lines of code. when i do some specific operation, i.e. open a very large document, the app almost eats up my memory. but after a while, the memory is given back. i have tested the codes and found no memory leak. so, my problem is how to find the codes who eat up my memory. any one can help me?

                A Offline
                A Offline
                Alan Balkany
                wrote on last edited by
                #7

                The C# garbage collector is non-deterministic, which means it runs somewhat "randomly". It can produce this behavior even if there are no memory leaks in your application. It just delays collecting the disposed memory until it needs it. You can, however, explicitly invoke the garbage collector from your code:

                System.GC.Collect ();

                "Microsoft -- Adding unnecessary complexity to your work since 1987!"

                1 Reply Last reply
                0
                • F Falconapollo

                  i have a appilcation consists of thousands lines of code. when i do some specific operation, i.e. open a very large document, the app almost eats up my memory. but after a while, the memory is given back. i have tested the codes and found no memory leak. so, my problem is how to find the codes who eat up my memory. any one can help me?

                  J Offline
                  J Offline
                  Joe Woodbury
                  wrote on last edited by
                  #8

                  First, when you do a malloc or new, you extend the heap. For optimization reasons, the memory manager may not return the heap back to the OS immediately. When needing to allocate especially large chunks of memory, you can use a low level API directly or, with some compilers/CRTs, a different heap (for Windows, here's an article discussion various options: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366533%28v=vs.85%29.aspx[^].) Also note that if you allocate memory and sit around, the OS may page it out. To understand the difference in Windows, look into "private bytes" and "working set".

                  1 Reply Last reply
                  0
                  • F Falconapollo

                    i have a appilcation consists of thousands lines of code. when i do some specific operation, i.e. open a very large document, the app almost eats up my memory. but after a while, the memory is given back. i have tested the codes and found no memory leak. so, my problem is how to find the codes who eat up my memory. any one can help me?

                    V Offline
                    V Offline
                    vr999999999
                    wrote on last edited by
                    #9

                    most of the time this problem is due to memory leak u check it again also check may be there is some large array defined in the code.like int arr[1024*1024][1024*1024].

                    1 Reply Last reply
                    0
                    • F Falconapollo

                      i have a appilcation consists of thousands lines of code. when i do some specific operation, i.e. open a very large document, the app almost eats up my memory. but after a while, the memory is given back. i have tested the codes and found no memory leak. so, my problem is how to find the codes who eat up my memory. any one can help me?

                      P Offline
                      P Offline
                      PecuniousPete
                      wrote on last edited by
                      #10

                      application verifier is a good start.

                      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