April 1st, 2011, 10:44 AM
VS2005 MFC Debugger Stopping Time
I've been writing an MFC programme in VS2005 in C++ and have recently run into some issues during debugging. When I debug the code it will run perfectly well until the point I end the debugging process (either by closing the MFC window or through the menus/toolbars within Visual Studio). Visual Studio will take quite some time to finish the debugging process and give me full control of the programme again. The sort of time I'm meaning can vary from 5-10 seconds to many, many minutes (so long that last night I had to leave my computer on overnight and came back this morning to find that it had finished - in other words, too long to sit around and wait but it's not completely hanging, it will recover eventually).
Basically, since I'm not a vastly experienced programmer, I'd like some information as to why this might be. Is it a problem with VS2005? Is it due to my code? Or is it something else?
I've seen various posts on the web about problems with the VS2005 debugger, but can't find one about this specific problem (e.g. lots about problems stepping between breakpoints, but my actual code runs fine up to the point when I want to stop debugging).
I'm not expecting anyone to look through the masses of code to find an error, as I doubt it is any specific lines since the programme compiles and executes fine, but I'm wondering two things:
1. What is it that the debugger actually does after I click "stop debugging"
2. Could the problem be due to memory allocation (as I'm estimating at the moment)
For question 1, I'd quite like to find out what it's doing. For question 2, I can tell you that my code creates several 1D and 2D arrays during it's operation, but I delete them asap (which I though would mean the debugger would have less work to do itself at the end to delete everything). The methods I use to create and delete the arrays are as follows:
// create 1D array
new1DArray = new double[nRows];
// create 2D array
new2DArray = new double*[nRows];
for(row = 0; row < nRows; row++) new2DArray[row] = new double[nColumns];
// delete 1D array
// delete 2D array
for(row = 0; row < nRows; row++) delete new2DArray[row];
The reason why I think this could be the cause is that the time taken to "stop debugging" (as I said above, it varies greatly) increases dramatically once I increase the scale of the problem that my programming is tackling - in other words, as the scale of the problem increases, the sizes of the arrays increase and also the number of arrays created and deleted increase too.
I hope this all makes sense, and that you can see what my issue is. Any assistance in finding a solution, or advice in how to better program to avoid this problem, will be greatly appreciated.
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!