diff --git a/src/Dataloaders.jl b/src/Dataloaders.jl index 22397a327ae52174c17a57387d9a7c25a084680f..47cda65f4d14c8abfbcd018fd743484de2f3d473 100644 --- a/src/Dataloaders.jl +++ b/src/Dataloaders.jl @@ -193,7 +193,7 @@ function countlabels(repository, window; unload=false) counts′[label] = get(counts′, label, 0) + 1 end end - unload && unload!(file) + unload && unload!(file; gc=true) lock(c) try counts[file] = counts′ @@ -501,8 +501,8 @@ function sample(f, loader::DataLoader, features=:spine; kwargs...) Threads.foreach(ch) do (i, file, state) segments = sample(file, loader.window, loader.index, features; kwargs...) f(i, file, state, filter(!isnothing, segments)) - empty!(segments) # `unload!` calls `GC.gc` - unload!(file) + empty!(segments) + unload!(file; gc=true) end end diff --git a/src/Formats.jl b/src/Formats.jl index 127334971236a21c7c71a712bf8715cd1a7384ea..da926c5027ffa9e3c9dc4d06cc7aad12a53a82f5 100644 --- a/src/Formats.jl +++ b/src/Formats.jl @@ -539,20 +539,20 @@ end Unload timeseries data to free memory space. """ -function unload!(file::Formats.JSONLabels) +function unload!(file::Formats.JSONLabels; gc=false) for dep in file.dependencies unload!(dep) end empty!(file.dependencies) empty!(file.timeseries) empty!(file.run) - GC.gc() + gc && GC.gc() return file end -function unload!(file) +function unload!(file; gc=false) empty!(file.timeseries) empty!(file.run) - GC.gc() + gc && GC.gc() return file end