From 1fc9c8ee747d0ba775b17ccd245e1b1d76665224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Laurent?= <francois.laurent@posteo.net> Date: Wed, 24 May 2023 15:53:02 +0200 Subject: [PATCH] half the number of calls to gc --- src/Dataloaders.jl | 6 +++--- src/Formats.jl | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Dataloaders.jl b/src/Dataloaders.jl index 22397a3..47cda65 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 1273349..da926c5 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 -- GitLab