# Mmap problem with SharedArrays

**URL:** <https://discourse.julialang.org/t/mmap-problem-with-sharedarrays/31552>\
**Category:** Specific Domains\
**Tags:** first-steps, parallel, distributed\
**Created:** [November 26, 2019, 9:45pm UTC](https://discourse.julialang.org/t/mmap-problem-with-sharedarrays/31552 "2019-11-26T21:45:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmcastro2109](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmcastro2109/32/38427_2.png) [@jmcastro2109](https://discourse.julialang.org/u/jmcastro2109)\
**Post date:** [November 26, 2019, 9:45pm UTC](https://discourse.julialang.org/t/mmap-problem-with-sharedarrays/31552/1 "2019-11-26T21:45:38Z")

</div>

Hello, I am confronting a very weird problem when parallelizing some function. I understand that I am supposed to post a MWE but I could not recreate the issue in a simple problem.

```julia
@everywhere function simulSample(Profits,ν,J,TerminalT,RelevantT,N,S,params,thresh;RelevantPer=RelevantPeriod)
    Dₑ = rand([0],J,1) # Final Condition
    Dᵢ = rand([0],J,1) # Initial Condition
    tempData=SharedArray{Int8}(J,RelevantT,S*N)
    @inbounds @sync @distributed for n=1:S*N
    #for n=1:N
        #println(n)
        tempData[:,:,n]=solver(Dᵢ,Dₑ,Profits[:,:,n],continent,cont_lang,language,J,TerminalT,RelevantT,RelevantPeriod,params,thresh,ν[:,:,n])
    end
    return tempData
end

```

This function is being called by another function in an iterative procedure. In the first iteration it works, but in the second iteration I get the following error

SystemError: mmap the operation completed successfully

---

<div class="post-metadata">

**Author:** ![jmcastro2109](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmcastro2109/32/38427_2.png) [@jmcastro2109](https://discourse.julialang.org/u/jmcastro2109)\
**Post date:** [November 26, 2019, 11:08pm UTC](https://discourse.julialang.org/t/mmap-problem-with-sharedarrays/31552/2 "2019-11-26T23:08:20Z")

</div>

Some extra information might be useful. The time it runs in the first iteration, the @time provides the following information

`334.405107 seconds (963.79 M allocations: 50.295 GiB, 3.64% gc time)`

and the SharedArray tempData is of dimensions (47,11,17040)

---

<div class="post-metadata">

**Author:** ![jmcastro2109](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmcastro2109/32/38427_2.png) [@jmcastro2109](https://discourse.julialang.org/u/jmcastro2109)\
**Post date:** [November 27, 2019, 1:44pm UTC](https://discourse.julialang.org/t/mmap-problem-with-sharedarrays/31552/4 "2019-11-27T13:44:49Z")

</div>

any suggestion regarding this problem? It seems to me that there might be some memory problem. I tried to define the SharedArray in a local scope so that it deletes with each iteration but it seems to me that something might not be garbage collected.
