# Writing directly into ray shared memory

**URL:** <https://discuss.ray.io/t/writing-directly-into-ray-shared-memory/23286>\
**Category:** Ray Core\
**Created:** [October 30, 2025, 1:05pm UTC](https://discuss.ray.io/t/writing-directly-into-ray-shared-memory/23286 "2025-10-30T13:05:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shiranbi](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@shiranbi](https://discuss.ray.io/u/shiranbi)\
**Post date:** [October 30, 2025, 1:05pm UTC](https://discuss.ray.io/t/writing-directly-into-ray-shared-memory/23286/1 "2025-10-30T13:05:54Z")

</div>

Medium: Significantly affects my productivity but can find a workaround.

**i am guessing this isn’t an option but i’ll try anyway**

i am creating a large buffer as output of my ray task. Then when i give it as a return value, ray writes it to the plasma shared memory. So that is another memory write of the entire buffer.

if i was to receive a pointer to the shared memory directly i could write to it and avoid the extra copy

is this at all possibe?

---

<div class="post-metadata">

**Author:** ![RunLLM](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/runllm/32/8249_2.png) [@RunLLM](https://discuss.ray.io/u/RunLLM)\
**Post date:** [October 30, 2025, 1:06pm UTC](https://discuss.ray.io/t/writing-directly-into-ray-shared-memory/23286/2 "2025-10-30T13:06:27Z")

</div>

Currently, Ray does not support direct write access to the plasma shared memory buffer from within a task; when you return a large object (like a numpy array), Ray copies the data into the object store, resulting in an extra memory write. Zero-copy is only supported for reading numpy arrays from the object store (i.e., when you ray.get), not for writing—so you cannot obtain a pointer to the shared memory to write directly and avoid the copy at task return time. This limitation is acknowledged and tracked as a potential enhancement in the Ray project, but as of now, only zero-copy reads are supported, not zero-copy writes or in-place writes to plasma buffers by user code. For true shared-memory, in-place writes, you would need to use custom shared memory constructs outside of Ray’s object store, such as Python’s multiprocessing.shared\_memory, but this is not natively integrated with Ray’s object lifecycle or distributed features. See discussion and workarounds in the linked issue and forum posts for more details: [Ray GitHub Issue #48961](https://github.com/ray-project/ray/issues/48961), [Ray Discourse: How to share memory with non-numpy object](https://discuss.ray.io/t/core-how-to-share-memory-with-non-numpy-object/1295).

Would you like more detail or example code for possible workarounds?

Sources:

- [Ray GitHub Issue #48961](https://github.com/ray-project/ray/issues/48961)
- [Ray Discourse: How to share memory with non-numpy object](https://discuss.ray.io/t/core-how-to-share-memory-with-non-numpy-object/1295)

Hint: Mention @RunLLM in the post for followups.
