title: c++ How to test whether a certain bit of memory in the heap is free?
body: <p>I have some code:</p>
  
  <pre><code>int *ip = new int;
  
  *ip = 42;
  cout &lt;&lt; *ip &lt;&lt; endl;
  cout &lt;&lt; ip &lt;&lt; endl;
  
  delete ip;
  cout &lt;&lt; *ip &lt;&lt; endl;
  cout &lt;&lt; ip &lt;&lt; endl;
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>42
  0x100105400
  42
  0x100105400
  </code></pre>
  
  <p>From the value of the pointer and the value on the memory where it pointed to, I think I can't know whether the bit of memory in the heap pointed by <code>ip</code> is free?</p>
  
  <p>I know that if I were to add <code>delete ip;</code> again after my code, the compiler will throw an error. That will be a good evidence that the memory is free.</p>
  
  <p>But, how can I test whether it's free peacefully, so that I can use it as a condition to decide further operations in my code?</p>