|
-
Apr 27th, 2016, 08:07 AM
#1
Thread Starter
Fanatic Member
"A Heap has been corrupted." exception help
My program raises an unhandled exception when it runs as an .exe, but compiles and runs without error in the VS2010 environment. The exception does not occur every time I run the program.
Here is the error message...

Since it does not fail in the VS2010 environment I'm not sure how to find/trap/fix this error.
(FWIW this code was originally developed on a Win7Pro machine and has been running without problems for a couple of years. This error is now occurring on a Win10Pro machine.)
Appreciate any advice or direction on this issue.
-
Apr 27th, 2016, 08:33 AM
#2
Re: "A Heap has been corrupted." exception help
The error message alone is not going to be enough to diagnose this so some further investigation is going to be required.
First, I'm not clear from your post, is Money Manager Toolkit your program or is it a third party exe you run from your program? If it's the latter you'll need to contact the vendor for support.
If it's your own program then you're going to have to somehow start narrowing down where it's occurring. This will be a laborious process I'm afraid.
Personally I'd start by putting in some top level Try Catch blocks into your code. You want a block in every "action" (basically every event handler and the Sub Main) and, when you catch the error, log the stack trace. That will help you narrow down where the error is actually occurring. After that it's basically a case of looking at the code at that point and trying to work out what could cause the error - there's no easy way to do that and is going to involve a lot of trial and error.
Edit> It's also worth mentioning that, with a heap corruption, the exception will be thrown when the corruption is found rather than when it's caused. This makes them a sod to track down. Do you do any direct memory manipulation in your program? That's probably the place to start looking.
Last edited by FunkyDexter; Apr 27th, 2016 at 08:44 AM.
The best argument against democracy is a five minute conversation with the average voter - Winston Churchill
Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd
-
Apr 27th, 2016, 09:12 AM
#3
Thread Starter
Fanatic Member
Re: "A Heap has been corrupted." exception help
FunkyDexter - Thank you for your prompt reply. Yes, the Money Manager Toolkit is a program that I wrote a few years ago. The code uses Try/Catch structures in every subroutine and function. There is no direct memory management. I understand your point re:error catching and I am familar with single stepping through my code in the VBE, but I don't know how to isolate an error that only happens outside of the VS2010 environment.
I do think it is noteworthy that this program has only recently started throwing this error (after moving to a Win10Pro machine).
Thoughts?
-
Apr 27th, 2016, 09:36 AM
#4
Re: "A Heap has been corrupted." exception help
The code uses Try/Catch structures in every subroutine and function
It's not the subs and functions that are going to help you in this one, it's the entry points, i.e. the events. You need to catch the unhandled exceptions, i.e. the ones that aren't being caught in your subs. and then you need to output the stack trace to see where the exception actually occurred. Each event wants a blanket Catch Exception block to catch every possible error.
There is no direct memory management.
Hmm, that's surprising. I haven't seen a heap corruption in nearly two decades and back then the root cause was usually trying to de-allocate the same bit of memory twice as a result of bad pointer management. I've never seen it happen in a language like VB that runs with managed memory. In fact, as I ponder it I can't think of how it's even possible for it to occur in a managed memory environment like .Net.
Last edited by FunkyDexter; Apr 27th, 2016 at 09:40 AM.
The best argument against democracy is a five minute conversation with the average voter - Winston Churchill
Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|