memory heap problem
-
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
-
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
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 -
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
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 calldelete
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 intarray[10];
isarray[9]
because the first element isarray[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.:-DNothing is exactly what it seems but everything with seems can be unpicked.
-
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
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