unpin a mutable byte array
Sometimes, it necessary to allocate a mutable byte array as pinned. This commonly happens when the mutable byte array will immidiately be handed over to a safe
FFI routine to be initialized. However, after it has been initialized, it might not be useful for it to be pinned anymore. If it's a little byte array, it may contribute to a fragmented heap. Even if it's large, the fact that the user explicitly asked pin it prohibits it from ever being added to a compact region (pinned bytearrays that were pinned simply because they are over 3KB can be added to compact regions). A workaround for either of these problems is to copy the pinned bytearray into an unpinned byte array afterwards. But that's kind of wasteful. Is it possible to have a primop
unpinMutableByteArray :: MutableByteArray s -> State# s -> State# s
After this, the mutable byte array could be moved in memory. This would require isMutableByteArrayPinned#
to undergo a similar transition as sizeofMutableByteArray#
(which was superceeded by getSizeofMutableByteArray#
) underwent.
Is this possible? Or are pinned things allocated in a special place that makes unpinning impossible?
Trac metadata
Trac field | Value |
---|---|
Version | 8.6.2 |
Type | Task |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |