Skip to content

Memory leak in Base #50345

@schlichtanders

Description

@schlichtanders

Hi there

I found a small example to reproduce a memory leak which kept me busy for several days. (Hoping to find a workaround soon).

Running the following in Julia REPL several times will show an increase in memory usage (about 200 KB per run).

begin
forecast_samples = [randn(30) for i in 1:10_000]
sums = vec(mapslices(sum, reduce(vcat, forecast_samples'), dims=1))
GC.gc(); Base.gc_live_bytes() / 2^20
end

For sure this example is not yet minimal, but at least super tiny.

(tested on Julia 1.9.0 and 1.9.1)

EDIT: Just realized that gc_live_bytes is quite noisy. Hence better do the above a couple of times. E.g.

[begin
forecast_samples = [randn(30) for i in 1:10_000]
sums = vec(mapslices(sum, reduce(vcat, forecast_samples'), dims=1))
GC.gc(); Base.gc_live_bytes() / 2^20
end for i in 1:50]

Metadata

Metadata

Assignees

No one assigned

    Labels

    GCGarbage collector

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions