Yes, strictly speaking, releasing the buffer here is wrong. The correct fix would be to have a "managed buffer object" that releases the buffer when its refcount drops to 0. In other places in Numpy, we use the python memoryview object for that --- but it has no mechanism for requiring the contiguity. So we'd need to steal the managed buffer implementation from CPython sources...