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. debug mode VS execution mode

debug mode VS execution mode

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiodebuggingperformancehelpquestion
5 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.
  • A Offline
    A Offline
    Ayman Mashal
    wrote on last edited by
    #1

    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

    J T 2 Replies Last reply
    0
    • A Ayman Mashal

      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

      J Offline
      J Offline
      James R Twine
      wrote on last edited by
      #2

      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 to realloc(...) is broken, and it looks possible because there is no testing/verification visible in the code you provided, realloc(...) can return a NULL 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's CString) 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

      A 1 Reply Last reply
      0
      • J James R Twine

        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 to realloc(...) is broken, and it looks possible because there is no testing/verification visible in the code you provided, realloc(...) can return a NULL 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's CString) 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

        A Offline
        A Offline
        Ayman Mashal
        wrote on last edited by
        #3

        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 ? thanks

        D 1 Reply Last reply
        0
        • A Ayman Mashal

          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 ? thanks

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Ayman Mashal wrote:

          at some point realloc returns NULL !!!! why ?

          Gotta love realloc()!


          "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

          "Judge not by the eye but by the heart." - Native American Proverb

          1 Reply Last reply
          0
          • A Ayman Mashal

            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

            T Offline
            T Offline
            toxcct
            wrote on last edited by
            #5

            I reiterate : "Surviving The Release"[^] by Joseph Newcomer


            [VisualCalc][Binary Guide updated! ][CommDialogs new! ] | [Forums Guidelines]

            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