# Warning: macos 10.12.\* bug with SharedArray: shm\_open() failed

**URL:** <https://discourse.julialang.org/t/warning-macos-10-12-bug-with-sharedarray-shm-open-failed/10471>\
**Category:** Julia at Scale\
**Created:** [April 21, 2018, 9:04pm UTC](https://discourse.julialang.org/t/warning-macos-10-12-bug-with-sharedarray-shm-open-failed/10471 "2018-04-21T21:04:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![iwelch](https://avatars.discourse-cdn.com/v4/letter/i/8c91f0/32.png) [@iwelch](https://discourse.julialang.org/u/iwelch)\
**Post date:** [April 21, 2018, 9:04pm UTC](https://discourse.julialang.org/t/warning-macos-10-12-bug-with-sharedarray-shm-open-failed/10471/1 "2018-04-21T21:04:51Z")

</div>

The following program triggers a bug in macos `10.12.*`, but not in `10.13.*` :

```julia
(nprocs()>1) || addprocs(1)

function sharedarray_parallel_sum()
    sa = SharedArray{Float64}(5)
    @sync @parallel for i=1:5; sa[i] = timingfun(); end#for
    sum(sa)
end#function

@everywhere function timingfun(); return sqrt(2.0); end;

println("Number of Processors: $(nprocs()).")

## works with 100, but dies with 1000
for i=1:1_000; sharedarray_parallel_sum(); end

```

the precise bug is

```julia
Number of Processors: 2.
ERROR: LoadError: On worker 2:
SystemError: shm_open() failed for /jl047505QBT91bdhwS4cz86EgGYm: Too many open files
_link_pipe at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib:?
...

```

I have run it up to 100\_000 on `10.13.*`, and it does not trigger this bug.

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [January 9, 2019, 3:24pm UTC](https://discourse.julialang.org/t/warning-macos-10-12-bug-with-sharedarray-shm-open-failed/10471/2 "2019-01-09T15:24:48Z")

</div>

Any updates on this issue, a work around o something?. I hit the same problem. In my case sometimes works for 100, but for 200 definitely fails. And I am using MacOs 10.14.2

---

<div class="post-metadata">

**Author:** ![lazarusA](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lazarusa/32/6571_2.png) [@lazarusA](https://discourse.julialang.org/u/lazarusA)\
**Post date:** [January 9, 2019, 4:33pm UTC](https://discourse.julialang.org/t/warning-macos-10-12-bug-with-sharedarray-shm-open-failed/10471/3 "2019-01-09T16:33:06Z")

</div>

Never mind. I just called \* finalize \* once the SharedArray is not longer needed, and it works just fine.

> No. Sometimes works other don’t. The minimal example that I’m using is the following.
> 
> ![55%20PM](https://global.discourse-cdn.com/julialang/original/3X/b/b/bbe208edcbcd010595077b47ebdcff1198ca2ff2.png)

---

<div class="post-metadata">

**Author:** ![ankit13](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@ankit13](https://discourse.julialang.org/u/ankit13)\
**Post date:** [December 13, 2020, 10:23pm UTC](https://discourse.julialang.org/t/warning-macos-10-12-bug-with-sharedarray-shm-open-failed/10471/4 "2020-12-13T22:23:38Z")

</div>

Hi,  
Late reply, but might be relevant.

I recently had a similar error in Linux. What I found that there is a limit on the number of files you can create at a time in an operating system. And a shared array is like “creating a new file” in the memory.

Therefore, we can have a certain number of shared arrays at a time. I suggest rather than creating many small-sized shared arrays, create a few big-sized shared arrays.

Thanks.
