debug mode VS execution mode
-
Hi i want to know in terms of memory allocation what is the diffrence between the debug and execution mode i have a code that work fine in debug mode and finish successfuly while its faild in execution mode with the error : The instruction at "0x...etc" referenced memory at "0x000000002c" .The memory could not be "written" my code is :
for(i=0;i and the declaration of dSegment is `struct { unsigned int DC; int *segment; }dSegment;` thank in advance
-
Hi i want to know in terms of memory allocation what is the diffrence between the debug and execution mode i have a code that work fine in debug mode and finish successfuly while its faild in execution mode with the error : The instruction at "0x...etc" referenced memory at "0x000000002c" .The memory could not be "written" my code is :
for(i=0;i and the declaration of dSegment is `struct { unsigned int DC; int *segment; }dSegment;` thank in advance
Ayman Mashal wrote:
0x0000002c
That address tells you that you likely did something off of a
NULL
pointer, so I would start there. If the calculation of the memory size used in the call torealloc(...)
is broken, and it looks possible because there is no testing/verification visible in the code you provided,realloc(...)
can return aNULL
value, and the following line would cause an exception in that case. BTW - the allocation differences between release and debug are many, and some objects (like MFC'sCString
) even allocate memory differently in release mode than in debug mode (it allocates exact amounts in debug, but allcoates in blocks in release). The first thing is that under debug mode, memory allocation routines will often pad allocated memory with special bytes allowing you to detect overruns. Are you sure that you have no memory-related issues in debug mode? You have to run the program to completion to find all of them, not just stop it in the debugger. Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFiles -
Ayman Mashal wrote:
0x0000002c
That address tells you that you likely did something off of a
NULL
pointer, so I would start there. If the calculation of the memory size used in the call torealloc(...)
is broken, and it looks possible because there is no testing/verification visible in the code you provided,realloc(...)
can return aNULL
value, and the following line would cause an exception in that case. BTW - the allocation differences between release and debug are many, and some objects (like MFC'sCString
) even allocate memory differently in release mode than in debug mode (it allocates exact amounts in debug, but allcoates in blocks in release). The first thing is that under debug mode, memory allocation routines will often pad allocated memory with special bytes allowing you to detect overruns. Are you sure that you have no memory-related issues in debug mode? You have to run the program to completion to find all of them, not just stop it in the debugger. Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFilesyou are right at some point realloc returns NULL !!!! why ? the calculation of the memory size is fine i put some print messages in the code and here is the output : DC: 0 before realloc : 0 after realloc : 323b78 DC: 1 before realloc : 323b78 after realloc : 323b78 DC: 2 before realloc : 323b78 after realloc : 323b78 DC: 3 before realloc : 323b78 after realloc : 323b20 DC: 4 before realloc : 323b20 after realloc : 323b20 DC: 5 before realloc : 323b20 after realloc : 323b20 DC: 6 before realloc : 323b20 after realloc : 323b20 DC: 7 before realloc : 323b20 after realloc : 323b20 DC: 8 before realloc : 323b20 after realloc : 323b20 DC: 9 before realloc : 323b20 after realloc : 323b20 DC: 10 before realloc : 323b20 after realloc : 323b20 DC: 11 before realloc : 323b20 after realloc : 323b20 DC: 12 before realloc : 323b20 after realloc : 323b20 DC: 13 before realloc : 323b20 after realloc : 323b20 DC: 14 before realloc : 323b20 after realloc : 323b20 DC: 15 before realloc : 323b20 after realloc : 323bc0 DC: 16 before realloc : 323bc0 after realloc : 323bc0 DC: 17 before realloc : 323bc0 after realloc : 323bc0 DC: 18 before realloc : 323bc0 after realloc : 323bc0 DC: 19 before realloc : 323bc0
**after realloc : 0**
note that if i decrease my string length its work fine !! is there any place in the project setting the sets the allowed space for the programme ? thanks -
you are right at some point realloc returns NULL !!!! why ? the calculation of the memory size is fine i put some print messages in the code and here is the output : DC: 0 before realloc : 0 after realloc : 323b78 DC: 1 before realloc : 323b78 after realloc : 323b78 DC: 2 before realloc : 323b78 after realloc : 323b78 DC: 3 before realloc : 323b78 after realloc : 323b20 DC: 4 before realloc : 323b20 after realloc : 323b20 DC: 5 before realloc : 323b20 after realloc : 323b20 DC: 6 before realloc : 323b20 after realloc : 323b20 DC: 7 before realloc : 323b20 after realloc : 323b20 DC: 8 before realloc : 323b20 after realloc : 323b20 DC: 9 before realloc : 323b20 after realloc : 323b20 DC: 10 before realloc : 323b20 after realloc : 323b20 DC: 11 before realloc : 323b20 after realloc : 323b20 DC: 12 before realloc : 323b20 after realloc : 323b20 DC: 13 before realloc : 323b20 after realloc : 323b20 DC: 14 before realloc : 323b20 after realloc : 323b20 DC: 15 before realloc : 323b20 after realloc : 323bc0 DC: 16 before realloc : 323bc0 after realloc : 323bc0 DC: 17 before realloc : 323bc0 after realloc : 323bc0 DC: 18 before realloc : 323bc0 after realloc : 323bc0 DC: 19 before realloc : 323bc0
**after realloc : 0**
note that if i decrease my string length its work fine !! is there any place in the project setting the sets the allowed space for the programme ? thanksAyman Mashal wrote:
at some point realloc returns NULL !!!! why ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Hi i want to know in terms of memory allocation what is the diffrence between the debug and execution mode i have a code that work fine in debug mode and finish successfuly while its faild in execution mode with the error : The instruction at "0x...etc" referenced memory at "0x000000002c" .The memory could not be "written" my code is :
for(i=0;i and the declaration of dSegment is `struct { unsigned int DC; int *segment; }dSegment;` thank in advance
I reiterate : "Surviving The Release"[^] by Joseph Newcomer
[VisualCalc][Binary Guide updated! ][CommDialogs new! ] | [Forums Guidelines]