New Issue: Add a way to manually manage the buffer lifetime of managed types?

18164, "ronawho", "Add a way to manually manage the buffer lifetime of managed types?", "2021-08-05T00:32:26Z"

Types like bytes/strings/arrays are effectively owned and they are destroyed when they go out of scope. However, there are some cases where we want to take ownership of the underlying memory used by these types. ZMQ send() is an example of this where we want to pass the underlying buffer form a bytes/string to ZMQ and have ZMQ be responsible for free'ing the memory later. Currently ZMQ manually sets bytes.isOwned = false, but this is hooking into internal implementation details.

I'm wondering if we can make a user-facing version of this, ideally something that's consistent with our managed memory interfaces for owned/shared. Throwing out a proposal maybe something like bytes.buffer.release().

Where buffer would be an interface for types that have buffers like this (similar to pythons buffer protocol), and release is I think what owned/shared support as a way to give up ownership.