Skip to content

Memory leak when repeatedly benchmarking #339

@LilithHafner

Description

@LilithHafner

I'm trying to benchmark sorting runtime as a function of input size. I have this function

using BenchmarkTools
function f(n)
    x = rand(Int, n)
    target = sort(x)
    y = copy(target)
    @belapsed sort!($y) setup=($y == $target || error("Bad sort"); copyto!($y, $x)) evals=1 gctrial=false samples=3
end

But that function is a significant memory leak (because of JuliaLang/julia#14495)

If I run times = f.(1594323:1594323+100) (100 data points), it leaks about 3.56 GB according to my OS's report of how much memory the Julia process is using. Repeated runs continue to leak until my system crashes.

Is there a way to run @belapsed without leaking memory?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions