This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author OH
Recipients OH, paul.moore, steve.dower, tim.golden, zach.ware
Date 2020-02-16.19:13:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1581880426.57.0.187010353913.issue39655@roundup.psfhosted.org>
In-reply-to
Content
Shared Memory is attaching to incorrect memory location ,
ex : retried the documentation example.

>>> import numpy as np
>>> a = np.array([1, 1, 2, 3, 5, 8])
>>> from multiprocessing import shared_memory
>>> shm = shared_memory.SharedMemory(create=True, size=a.nbytes)
>>> b = np.ndarray(a.shape, dtype=a.dtype, buffer=shm.buf)
>>> b[:] = a[:]
>>> b
array([1, 1, 2, 3, 5, 8])
>>> type(b)
<class 'numpy.ndarray'>
>>> type(a)
<class 'numpy.ndarray'>
>>> shm.name
'wnsm_62040dca'
>>> shm.buf
<memory at 0x000002AD10118DC0>

# In either the same shell or a new Python shell on the same machine

>>> import numpy as np
>>> from multiprocessing import shared_memory
>>> existing_shm = shared_memory.SharedMemory(name='wnsm_62040dca')
>>> c = np.ndarray((6,), dtype=np.int64, buffer=existing_shm.buf)
>>> c
array([ 4294967297, 12884901890, 34359738373,           0,           0,
                 0], dtype=int64)
>>> c[-1]
0
>>> existing_shm.buf
<memory at 0x000001CF627E8DC0>
History
Date User Action Args
2020-02-16 19:13:46OHsetrecipients: + OH, paul.moore, tim.golden, zach.ware, steve.dower
2020-02-16 19:13:46OHsetmessageid: <1581880426.57.0.187010353913.issue39655@roundup.psfhosted.org>
2020-02-16 19:13:46OHlinkissue39655 messages
2020-02-16 19:13:46OHcreate