title: Python 3.6: Why does pickle.dumps(nparray) permanently increase refcount?
body: <p>An np.ndarray, when pickled, increments reference counter from the dumps function, however the ref count is never decremented.</p>
  
  <p>Python 3.6.4 Anaconda
  Ubuntu 16.04.5 LTS
  numpy 1.16.0</p>
  
  <p>I have already tried converting to a list using numpy.array.tolist() however this method is far too slow.</p>
  
  <pre class="lang-py prettyprint-override"><code>import numpy as np
  import pickle
  import sys
  
  a = np.ndarray((10, 10), dtype=np.uint8)
  print(sys.getrefcount(a)) # 2
  pickle.dumps(a)
  print(sys.getrefcount(a)) # 3
  </code></pre>
  
  <p>I would expect the output to be 2, 2 due to the Py_DECREF that occurs in the pickler dumps function, however it remains.</p>
  
  <p>Output is 2, 3 and I cannot fix it. I am leaking memory like crazy.</p>
  
  <p>Currently digging into _pickle.c.</p>