-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
duplicateIndicates similar issues or pull requestsIndicates similar issues or pull requests
Description
Sorry to spill the beans, but I found another issue with GC and multithreading.
Something similar was already flagged in #31923 and closed.
It is reproducible on my windows (11 Pro, Version 10.0.22621, Build 22621) with julia installed today from https://julialang.org/downloads/ using the winget cmd (nice btw :) ).
Julia Version 1.10.0
Commit 3120989f39 (2023-12-25 18:01 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 8 × Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
Threads: 5 on 8 virtual cores
Environment:
JULIA_NUM_THREADS = 4
JULIA_REVISE_POLL = 1
(I also tested this on my unofficial linux Debian build v1.9.4 if that helps, same problem)
Here is my MWE:
# Multi-threaded copy
f(a) = begin
b = similar(a)
Threads.@threads for i in eachindex(a)
b[i] = a[i]
end
return b
end
a = zeros(300_000_000)
a = f(a)
GC.gc()
# This results in twice the memory, unexpected!?
a = nothing
GC.gc()
# no memory is freed
varinfo()
# Also check that occupied memory of a is zero
# Is memory just kept by julia/glibc/? for later use?
a = zeros(300_000_000)
GC.gc()
# Now three times the size of a is in memory
# What happens if f(a) is run again?
a = f(a)
GC.gc()
# Memory goes back to 2x size of a
# Now restart, and try the same without Threads.@threads in f()
# I find that memory behaves as expected, i.e. is freed.
Let me know if you need further info.
Thank you!
Metadata
Metadata
Assignees
Labels
duplicateIndicates similar issues or pull requestsIndicates similar issues or pull requests