<p dir="auto">With the following minimal example, I am seeing memory usage reach 10GB+ within seconds if I start Julia with <code class="notranslate">JULIA_NUM_THREADS=4</code> (no other options).</p>
<p dir="auto">If I only use single thread, memory usage remains around 200MB.</p>
<p dir="auto">I've tested on both the 1.1 release and yesterday's nightly on a Linux Skylake Xeon.</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="Threads.@threads for i in 1:100000
    sum(collect(1:10^6))
end"><pre class="notranslate">Threads<span class="pl-k">.</span><span class="pl-c1">@threads</span> <span class="pl-k">for</span> i <span class="pl-k">in</span> <span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">100000</span>
    <span class="pl-c1">sum</span>(<span class="pl-c1">collect</span>(<span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">10</span><span class="pl-k">^</span><span class="pl-c1">6</span>))
<span class="pl-k">end</span></pre></div>
<p dir="auto">Running under TSAN with <code class="notranslate">JULIA_NUM_THREADS=4</code> gives the following warning:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="WARNING: ThreadSanitizer: data race (pid=32587)
  Write of size 8 at 0x7f82ec049d80 by thread T3:
    #0 jl_gc_pool_alloc /home/vchuravy/src/julia/src/gc.c:959:9 (libjulia.so.0.7+0xc2da4)
    #1 jl_gc_alloc_ /home/vchuravy/src/julia/src/./julia_internal.h:274:13 (libjulia.so.0.7+0x7a031)
    #2 jl_init_root_task /home/vchuravy/src/julia/src/task.c:714 (libjulia.so.0.7+0x7a031)
    #3 ti_threadfun /home/vchuravy/src/julia/src/threading.c:367:5 (libjulia.so.0.7+0xbe187)

  Previous write of size 8 at 0x7f82ec049d80 by thread T2:
    #0 jl_gc_pool_alloc /home/vchuravy/src/julia/src/gc.c:959:9 (libjulia.so.0.7+0xc2da4)
    #1 jl_gc_alloc_ /home/vchuravy/src/julia/src/./julia_internal.h:274:13 (libjulia.so.0.7+0x7a031)
    #2 jl_init_root_task /home/vchuravy/src/julia/src/task.c:714 (libjulia.so.0.7+0x7a031)
    #3 ti_threadfun /home/vchuravy/src/julia/src/threading.c:367:5 (libjulia.so.0.7+0xbe187)

  Location is global 'gc_num' of size 104 at 0x7f82ec049d80 (libjulia.so.0.7+0x00000057fd80)

  Thread T3 (tid=32591, running) created by main thread at:
    #0 pthread_create /home/vchuravy/src/julia/deps/srccache/llvm-6.0.0/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:992:3 (julia+0x40f766)
    #1 uv_thread_create /home/vchuravy/src/julia/deps/srccache/libuv-be317349252699670131395f125c3861d793ca86/src/unix/thread.c:76:9 (libjulia.so.0.7+0x247f22)
    #2 _julia_init /home/vchuravy/src/julia/src/init.c:726:5 (libjulia.so.0.7+0x768dc)
    #3 julia_init__threading /home/vchuravy/src/julia/src/task.c:302:5 (libjulia.so.0.7+0x79420)
    #4 main /home/vchuravy/src/julia/ui/repl.c:234:5 (julia+0x4994d3)

  Thread T2 (tid=32590, running) created by main thread at:
    #0 pthread_create /home/vchuravy/src/julia/deps/srccache/llvm-6.0.0/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:992:3 (julia+0x40f766)
    #1 uv_thread_create /home/vchuravy/src/julia/deps/srccache/libuv-be317349252699670131395f125c3861d793ca86/src/unix/thread.c:76:9 (libjulia.so.0.7+0x247f22)
    #2 _julia_init /home/vchuravy/src/julia/src/init.c:726:5 (libjulia.so.0.7+0x768dc)
    #3 julia_init__threading /home/vchuravy/src/julia/src/task.c:302:5 (libjulia.so.0.7+0x79420)
    #4 main /home/vchuravy/src/julia/ui/repl.c:234:5 (julia+0x4994d3)

SUMMARY: ThreadSanitizer: data race /home/vchuravy/src/julia/src/gc.c:959:9 in jl_gc_pool_alloc"><pre class="notranslate"><code class="notranslate">WARNING: ThreadSanitizer: data race (pid=32587)
  Write of size 8 at 0x7f82ec049d80 by thread T3:
    #0 jl_gc_pool_alloc /home/vchuravy/src/julia/src/gc.c:959:9 (libjulia.so.0.7+0xc2da4)
    #1 jl_gc_alloc_ /home/vchuravy/src/julia/src/./julia_internal.h:274:13 (libjulia.so.0.7+0x7a031)
    #2 jl_init_root_task /home/vchuravy/src/julia/src/task.c:714 (libjulia.so.0.7+0x7a031)
    #3 ti_threadfun /home/vchuravy/src/julia/src/threading.c:367:5 (libjulia.so.0.7+0xbe187)

  Previous write of size 8 at 0x7f82ec049d80 by thread T2:
    #0 jl_gc_pool_alloc /home/vchuravy/src/julia/src/gc.c:959:9 (libjulia.so.0.7+0xc2da4)
    #1 jl_gc_alloc_ /home/vchuravy/src/julia/src/./julia_internal.h:274:13 (libjulia.so.0.7+0x7a031)
    #2 jl_init_root_task /home/vchuravy/src/julia/src/task.c:714 (libjulia.so.0.7+0x7a031)
    #3 ti_threadfun /home/vchuravy/src/julia/src/threading.c:367:5 (libjulia.so.0.7+0xbe187)

  Location is global 'gc_num' of size 104 at 0x7f82ec049d80 (libjulia.so.0.7+0x00000057fd80)

  Thread T3 (tid=32591, running) created by main thread at:
    #0 pthread_create /home/vchuravy/src/julia/deps/srccache/llvm-6.0.0/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:992:3 (julia+0x40f766)
    #1 uv_thread_create /home/vchuravy/src/julia/deps/srccache/libuv-be317349252699670131395f125c3861d793ca86/src/unix/thread.c:76:9 (libjulia.so.0.7+0x247f22)
    #2 _julia_init /home/vchuravy/src/julia/src/init.c:726:5 (libjulia.so.0.7+0x768dc)
    #3 julia_init__threading /home/vchuravy/src/julia/src/task.c:302:5 (libjulia.so.0.7+0x79420)
    #4 main /home/vchuravy/src/julia/ui/repl.c:234:5 (julia+0x4994d3)

  Thread T2 (tid=32590, running) created by main thread at:
    #0 pthread_create /home/vchuravy/src/julia/deps/srccache/llvm-6.0.0/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:992:3 (julia+0x40f766)
    #1 uv_thread_create /home/vchuravy/src/julia/deps/srccache/libuv-be317349252699670131395f125c3861d793ca86/src/unix/thread.c:76:9 (libjulia.so.0.7+0x247f22)
    #2 _julia_init /home/vchuravy/src/julia/src/init.c:726:5 (libjulia.so.0.7+0x768dc)
    #3 julia_init__threading /home/vchuravy/src/julia/src/task.c:302:5 (libjulia.so.0.7+0x79420)
    #4 main /home/vchuravy/src/julia/ui/repl.c:234:5 (julia+0x4994d3)

SUMMARY: ThreadSanitizer: data race /home/vchuravy/src/julia/src/gc.c:959:9 in jl_gc_pool_alloc
</code></pre></div>
<p dir="auto">--edit: Already has a <code class="notranslate">// FIXME - need JL_ATOMIC_FETCH_AND_ADD here</code> annotation</p>