# Is it possible to define custom shared type for multiprocessing?

**URL:** https://discourse.julialang.org/t/is-it-possible-to-define-custom-shared-type-for-multiprocessing/21763
**Category:** General Usage
**Created:** [March 12, 2019, 2:44am UTC](https://discourse.julialang.org/t/is-it-possible-to-define-custom-shared-type-for-multiprocessing/21763 "2019-03-12T02:44:07Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Chong\_Wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chong_wang/32/20307_2.png) [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)
#### Post date: [March 12, 2019, 2:44am UTC](https://discourse.julialang.org/t/is-it-possible-to-define-custom-shared-type-for-multiprocessing/21763/1 "2019-03-12T02:44:07Z")

</div>

I have a type looking like

```julia
struct TBModel
    norbits::Int64
    lat::SMatrix{3,3,Float64,9}
    hoppings::Dict{SVector{3,Int64},Matrix{Float64}}
    overlaps::Dict{SVector{3,Int64},Matrix{Float64}}
    positions::Dict{SVector{3,Int64},SVector{3,Matrix{Float64}}}
end

```

Generally, a `TBModel` is huge (~4GB). My program initiates a `TBModel` and then calculate related quantities by multiprocessing.

Since the size of `TBModel` is large, I would like to avoid the situation where each process has its own copy of the instance. Since I only need to read (rather than write) a `TBModel` from the child processes, is it possible to share the data across all the processes just like `SharedArray`?

I am aware of multithreading functionality. However, many packages that I use are not thread-safe yet and I want to avoid such kind of pitfalls.
