Skip to content
Snippets Groups Projects
Commit 2aed6459 authored by François  LAURENT's avatar François LAURENT
Browse files

explicit calls to GC.gc

parent 0570b989
No related branches found
No related tags found
No related merge requests found
Pipeline #104305 passed
......@@ -76,8 +76,8 @@ Base.maximum(s::TimeSegment) = round(s.anchortime + s.window.durationafter; digi
extendedmin(s::TimeSegment) = round(s.anchortime - s.window.durationbefore - s.window.marginbefore; digits=4)
extendedmax(s::TimeSegment) = round(s.anchortime + s.window.durationafter + s.window.marginafter; digits=4)
LarvaBase.times(s::TimeSegment) = [round(t; digits=4) for t in range(minimum(s), maximum(s), length(s))]
extendedtimes(s::TimeSegment) = [round(t; digits=4) for t in range(extendedmin(s), extendedmax(s), extendedlength(s))]
LarvaBase.times(s::TimeSegment) = [round(t; digits=4) for t in range(minimum(s), maximum(s); length=length(s))]
extendedtimes(s::TimeSegment) = [round(t; digits=4) for t in range(extendedmin(s), extendedmax(s); length=extendedlength(s))]
LarvaBase.times(w::TimeWindow, t) = times(TimeSegment(nothing, t, w, nothing, nothing))
extendedtimes(w::TimeWindow, t) = extendedtimes(TimeSegment(nothing, t, w, nothing, nothing))
......@@ -94,7 +94,7 @@ function indicator(window::TimeWindow, segment::TimeSegment)
@assert window === segment.window
m = round(Int, window.marginbefore * window.samplerate)
n = length(window)
range(m + 1, m + n)
range(m + 1, m + n; step=1)
end
function segment(file, window, trackid, step, class)
......@@ -193,13 +193,13 @@ function countlabels(repository, window; unload=false)
counts′[label] = get(counts′, label, 0) + 1
end
end
unload && unload!(file)
lock(c)
try
counts[file] = counts′
finally
unlock(c)
end
unload && unload!(file)
end
return counts
end
......@@ -501,6 +501,7 @@ 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)
end
end
......
......@@ -540,15 +540,20 @@ end
Unload timeseries data to free memory space.
"""
function unload!(file::Formats.JSONLabels)
empty!(file.timeseries)
empty!(file.run)
for dep in file.dependencies
unload!(dep)
end
empty!(file.dependencies)
empty!(file.timeseries)
empty!(file.run)
GC.gc()
return file
end
function unload!(file)
empty!(file.timeseries)
empty!(file.run)
GC.gc()
return file
end
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment