# Shared array between two julia sessions with different pids

**URL:** <https://discourse.julialang.org/t/shared-array-between-two-julia-sessions-with-different-pids/97107>\
**Category:** General Usage\
**Created:** [April 5, 2023, 9:37am UTC](https://discourse.julialang.org/t/shared-array-between-two-julia-sessions-with-different-pids/97107 "2023-04-05T09:37:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrey2185](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrey2185/32/9889_2.png) [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Post date:** [April 5, 2023, 9:37am UTC](https://discourse.julialang.org/t/shared-array-between-two-julia-sessions-with-different-pids/97107/1 "2023-04-05T09:37:56Z")

</div>

**Process 26012:**

```julia
julia> using SharedArrays

julia> getpid()
26012

julia> sa = SharedVector{Int}(4);

```

**Process 35208:**

```julia
julia> using SharedArrays

julia> getpid()
35208

```

Is there an easy way to get `sa` from process 26012 in process 35208 ?  
All processes on one host.

---

<div class="post-metadata">

**Author:** ![andrey2185](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrey2185/32/9889_2.png) [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Post date:** [April 5, 2023, 9:58am UTC](https://discourse.julialang.org/t/shared-array-between-two-julia-sessions-with-different-pids/97107/2 "2023-04-05T09:58:45Z")

</div>

![image](https://global.discourse-cdn.com/julialang/original/3X/7/f/7f2e593167c3e998b205e80e14b3d2da6580a76f.png)

---

<div class="post-metadata">

**Author:** ![ianfiske](https://avatars.discourse-cdn.com/v4/letter/i/58f4c7/32.png) [@ianfiske](https://discourse.julialang.org/u/ianfiske)\
**Post date:** [April 5, 2023, 1:12pm UTC](https://discourse.julialang.org/t/shared-array-between-two-julia-sessions-with-different-pids/97107/3 "2023-04-05T13:12:15Z")

</div>

You might benefit from looking at this section in the manual [Multi-processing and Distributed Computing · The Julia Language](https://docs.julialang.org/en/v1/manual/distributed-computing/#man-shared-arrays). The separate process need to be worker processes spawned by the main julia process. There is a running example in that section of the manual.

---

<div class="post-metadata">

**Author:** ![andrey2185](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrey2185/32/9889_2.png) [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Post date:** [April 5, 2023, 1:26pm UTC](https://discourse.julialang.org/t/shared-array-between-two-julia-sessions-with-different-pids/97107/4 "2023-04-05T13:26:44Z")

</div>

thanks, but two independent sessions is a must

---

<div class="post-metadata">

**Author:** ![barucden](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barucden/32/26154_2.png) [@barucden](https://discourse.julialang.org/u/barucden)\
**Post date:** [April 5, 2023, 1:41pm UTC](https://discourse.julialang.org/t/shared-array-between-two-julia-sessions-with-different-pids/97107/5 "2023-04-05T13:41:01Z")

</div>

Mmap might help:  
[https://docs.julialang.org/en/v1/stdlib/Mmap/#Mmap.mmap](https://docs.julialang.org/en/v1/stdlib/Mmap/#Mmap.mmap)

---

<div class="post-metadata">

**Author:** ![andrey2185](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrey2185/32/9889_2.png) [@andrey2185](https://discourse.julialang.org/u/andrey2185)\
**Post date:** [April 5, 2023, 8:18pm UTC](https://discourse.julialang.org/t/shared-array-between-two-julia-sessions-with-different-pids/97107/6 "2023-04-05T20:18:15Z")

</div>

> **[GitHub - emmt/InterProcessCommunication.jl: Inter-process communication for...](https://github.com/emmt/InterProcessCommunication.jl)**
>
> Inter-process communication for Julia. Contribute to emmt/InterProcessCommunication.jl development by creating an account on GitHub.

```julia
using InterProcessCommunication

# then use WrappedArray(...);

```
