Skip to content

IOBuffer/fileIO Memory leak with Threads.@spawn #49545

Closed
@louisponet

Description

@louisponet

I managed to isolate a memory leak that caused runaway memory usage for long running processes due to some logging I was doing.

MWE:

function explode(lck, buffer, path, message; kwargs...)
    lock(buffer) do
        println(buffer, message)
        open(path, append = true) do f
            write(f, take!(buffer))
        end
    end
end

let
    lck = ReentrantLock()
    buffer = IOBuffer()
    path = "test.log"
    while true
        Threads.@spawn begin
            explode(lck, buffer, path, "blabla")
        end
    end
end

versioninfo():

Julia Version 1.9.0-rc2
Commit 72aec423c2 (2023-04-01 10:41 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: 8 × Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, skylake)
  Threads: 8 on 8 virtual cores
Environment:
  LD_LIBRARY_PATH = /opt/intel/compilers_and_libraries_2020.4.304/linux/compiler/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.4.304/linux/mkl/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.4.304/linux/compiler/lib/intel64_lin:/opt/intel/compilers_and_libraries_2020.4.304/linux/mkl/lib/intel64_lin
  JULIA_NUM_THREADS = 8

Compiled from source. Also tested on downloaded binaries of julia 1.8.2 , 1.6.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    GCGarbage collectorregressionRegression in behavior compared to a previous versionregression 1.9Regression in the 1.9 release

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions