Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Crashing</strong> is normally caused by an illegal instruction, e.g. accessing invalid memory, dividing by zero, etc. Usually this manifests itself as a well-known exception which is handled by the operating system.</p> <p><strong>Hanging</strong> can be broken up into 2 fairly high level categories:</p> <ul> <li><strong>Deadlock</strong>, usually caused by 2 threads competing for a resource, each requiring a resource held by the other thread to be released. A common cause of this is acquiring multiple locks in inconsistent orders within multiple threads, leading to the common <a href="https://stackoverflow.com/questions/1892619/threads-and-simple-dead-lock-cure/1892640#1892640">ABBA deadlock pattern</a> (and no this has nothing to do with Swedish pop music).</li> <li><strong>Livelock</strong>, which means that the code is still actively running, but you have reached a state that you cannot leave. For example: <ul> <li>The state of 2 processes/threads keep changing, never reaching an end condition</li> <li>A <em>while loop</em> where the exit condition will never be satisfied, or an <em>indefinite loop</em> (although this is stretching the definition of "livelock").</li> </ul></li> </ul> <p><em>Update based on question comment</em></p> <blockquote> <p>@Pop, Kristo: Am actually checking on a code that hangs but I see some problems on memory leak. But I'm not really sure if memory leak causes a program to hang. – jasonline</p> </blockquote> <p>A memory leak can cause a program to crash, but this depends on various factors:</p> <ul> <li>Size of leak</li> <li>Frequency of leak</li> <li>Lifetime of application</li> </ul> <p>Memory leaks may result in 2 bad things - a continual increase in memory usage by the process, and memory fragmentation. Both of these can result in failure to allocate memory down the line, if the OS cannot provide a contiguous block of memory.</p> <p>In C++, if the <code>new</code> operator fails to allocate memory, a <code>std::bad_alloc</code> exception will be thrown. This will most likely be caught by the OS, resulting in a crash (unless you have written a specific handler in your application for this exception, and are able to handle it more gracefully).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload