[issue46888] SharedMemory.close() destroys memory
Steve Dower
report at bugs.python.org
Tue Mar 1 07:17:47 EST 2022
Steve Dower <steve.dower at python.org> added the comment:
Yes, named memory mappings only exist on Windows until the last
reference is closed, so this is a difference due to the underlying OS.
The implementation of unlink() recognises this (the entire body is under
a _USE_POSIX check), but the docs do not reflect it.
The only workaround I can think of would be to create a real file, then
open it with mmap and give it a tagname, then pass that tagname as the
name argument of the shared memory object when creating it. It's a bit
of a pain, but I don't think there's any option on our side given the
way the API has been designed.
It's not possible for N SharedMemory instances to independently agree
which one will ignore the close() call and do it in unlink() instead,
and in any case that still wouldn't "unlink" the name until all other
references had also been closed.
Can you tell us a bit more about what you're trying to achieve? Perhaps
knowing how this is actually being relied upon will inspire some ideas
for how to make it work better.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46888>
_______________________________________
More information about the Python-bugs-list
mailing list