title: Cython: Memory view of freed memory
body: <p>In Cython code, I can allocate some memory and wrap it in a memory view, e.g. like this:</p>
  
  <pre><code>cdef double* ptr
  cdef double[::1] view
  ptr = &lt;double*&gt; PyMem_Malloc(N*sizeof('double'))
  view = &lt;double[:N]&gt; ptr
  </code></pre>
  
  <p>If I now free the memory using <code>PyMem_Free(ptr)</code>, trying to access elements like <code>ptr[i]</code> throws an error, as it should. However, I can safely try to access <code>view[i]</code> (it does not return the original data though).</p>
  
  <p>My question is this: Is it always safe to just deallocate the pointer? Is the memory view object somehow informed of the memory being freed, or should I manually remove the view somehow? Also, is the memory guaranteed to be freed, even though it is referred to by memory views?</p>