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 heap problem

memory heap problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpdebuggingc++testingbeta-testing
4 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
    Moonis Ahmed
    wrote on last edited by
    #1

    hi, i have an application which generates a signature for a file. the problem i am facing is when i run it, it gives the error : User breakpoint called from code at 0X77fcb940 and in the output window i get the following error: HEAP[UsageInstanceTool.exe]: Invalid Address specified to RtlFreeHeap( 3c0000, 818d58 ) I am testing the application in Release mode. There seems to be no problem in debug mode. I have no idea what the problem is since i am new to VC++ programming. waiting for help! - Moonis

    R M S 3 Replies Last reply
    0
    • M Moonis Ahmed

      hi, i have an application which generates a signature for a file. the problem i am facing is when i run it, it gives the error : User breakpoint called from code at 0X77fcb940 and in the output window i get the following error: HEAP[UsageInstanceTool.exe]: Invalid Address specified to RtlFreeHeap( 3c0000, 818d58 ) I am testing the application in Release mode. There seems to be no problem in debug mode. I have no idea what the problem is since i am new to VC++ programming. waiting for help! - Moonis

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

      Moonis Ahmed wrote:

      HEAP[UsageInstanceTool.exe]: Invalid Address specified to RtlFreeHeap( 3c0000, 818d58 )

      It seems like you're freeing an uninitialized pointer. Always initialize pointers by assigning NULL at declaration. That way you'll be able to test whether the pointer is valid or not. Also read this article[^].


      "It's supposed to be hard, otherwise anybody could do it!" - selfquote
      "High speed never compensates for wrong direction!" - unknown

      1 Reply Last reply
      0
      • M Moonis Ahmed

        hi, i have an application which generates a signature for a file. the problem i am facing is when i run it, it gives the error : User breakpoint called from code at 0X77fcb940 and in the output window i get the following error: HEAP[UsageInstanceTool.exe]: Invalid Address specified to RtlFreeHeap( 3c0000, 818d58 ) I am testing the application in Release mode. There seems to be no problem in debug mode. I have no idea what the problem is since i am new to VC++ programming. waiting for help! - Moonis

        M Offline
        M Offline
        Matthew Faithfull
        wrote on last edited by
        #3

        Hi, This looks like a memory overrun, probably on a buffer somewhere. In Debug VC++ pads out every allocation of memory you make with some extra bytes which can be used to see if you've overun the end of an array somewhere. It should report this but it doesn't always especially if you leak, i.e. don't delete, the whole array. In Release these extra bytes are missing and the same overrun will damage real data or code and you may see different behaviour. This is all a bit general but I dont know what your code looks like;) To be a bit more specific RTLFreeHeap is a built in Windows function that gets called when you call delete in your code. The 'Invalid Address' error means that it's trying to delete a pointer that was not the result of a new, could be uninitialised, or more often one that has already been deleted, or points at deleted memory. Check for duplicate delete calls and buffer overruns, remember if you're new to C++ that confusingly the lest element of int array[10]; is array[9] because the first element is array[0]. The best way to pick up memory issues like this in a small app is to run only parts of it, e.g start up and shutdown code only initially and keep adding more small sections back in until the problem appears in Release. You'll soon spot it.:-D

        Nothing is exactly what it seems but everything with seems can be unpicked.

        1 Reply Last reply
        0
        • M Moonis Ahmed

          hi, i have an application which generates a signature for a file. the problem i am facing is when i run it, it gives the error : User breakpoint called from code at 0X77fcb940 and in the output window i get the following error: HEAP[UsageInstanceTool.exe]: Invalid Address specified to RtlFreeHeap( 3c0000, 818d58 ) I am testing the application in Release mode. There seems to be no problem in debug mode. I have no idea what the problem is since i am new to VC++ programming. waiting for help! - Moonis

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #4

          I give the following advice about once a month; it often helps me track down the nastier heap errors: Try enabling the page heap[^] for your process. Follow these steps: 1. Download and install WinDBG[^]. 2. Select “Start”->“All Programs”->“Debugging Tools for Windows”->“Global Flags”. 3. Select the “Image File” tab. 4. In the “Image: (TAB to refresh)” edit control enter the name of your app then press TAB. Just the name with the extension; not the full path. 5. Tick the following: - “Enable page heap” - “Enable heap tail checking” - “Enable heap free checking” - “Enable heap parameter checking” - “Enable heap validation on call” - “Create user mode stack trace database” 6. Press “Apply”. 7. Debug your application. Any debugger will do but with WinDBG you have access to the stack traces of allocations via the !heap –p –a command, for example. When a heap problem is detected a breakpoint will be generated. 8. When done un-tick all the options you ticked, press “Apply” then dismiss GFlags. This step is important as if it’s skipped all applications named as entered in step 4 will run with the page heap enabled. Note that when using the page heap your application will run much slower than normal and consume way more memory. It’s good to have a beefy machine to do such tests; and such tests should be ran regularly on all applications you develop as part of regular testing activities. If I find a part of my application that’s too slow with the page heap enabled I optimize the memory allocation in that region.

          Steve

          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