release mode and debug mode

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #1

    release mode and debug mode

    Hi,
    What is the basic difference between release mode and debug mode.

    cause my developed win32 program perform fine in debug mode compilation. but when i try to release mode it run but control(edit control) do not return proper values. If i say more clearly
    [CODE
    GetDlgItemText( hWnd, USER, tempChar, 255); //tempChar wchar_t type
    [/CODE]

    above code return true value of the edit control in debug mode but in release mode it discard first two character.

    what point, possibly, i am missing?

    Please let me know.

    Best Regards,
    Johny
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    There are a number of differences most controlled by the switches you pass to the compiler.

    In debug mode normally you have optimisation switched off and output of debug information switched on and in release mode you have the opposite.

    However in debug mode the debug libraries often do different things when it comes to allocating memory from the heap. They often use sentinel values to show memory that has not been allocated, memory that has been allocated but not initialised and memory that has been freed to make it easier to see in the debugger if you are accessing a piece of memory that you shouldn't.

    In older debuggers there was also a feature where the debugger would automatically initialise uninitialised stack variables that could throw a spanner in the works.


    The most likely things that I can think of that are happening if you are getting different results in debug and release mode are
    • Your memory handling is not quite correct but it only shows up in release because of the alternate way memory allocation is handled in debug.
    • You have a race condition in a multi-threaded program. This is effected by the optimised code.
    • You have other unspecified undefined behaviour. Since undefined behaviour allows the program to do anything and that behaviour to change on a whim working in debug and not working in release is a definate possibility.


    If you can find anything of that nature they you will have to resort to the time honoured method of outputting messages to show program progress to try and diagnose the problem.

    Comment

    • johny10151981
      Top Contributor
      • Jan 2010
      • 1059

      #3
      Yes I think Memory Handler is making some trouble. Thanks for the reply

      Comment

      Working...