Skip to content

GC.gc() unable to free memory in the scope it is called from? #51818

@Tortar

Description

@Tortar

I opened some days ago this issue here: apache/arrow-julia#492. But after experimenting quite a bit I think this is a GC issue.

MWE (which I runned in REPL mode) similar as the one reported here https://discourse.julialang.org/t/how-to-force-an-object-to-be-freed-by-the-garbage-collector/77985:

function testme()
    X = rand(1_000_000_00)
    Y = sum(X)
    X = nothing
    GC.gc(); GC.gc(); GC.gc()
    return Y
end

function tester()
    Y = testme()
    return Y
end

tester()
# GC.gc() here frees it

the memory occupied by X is not freed, if I put after the call to tester a GC call instead it is.

Version Info:

julia> versioninfo()
Julia Version 1.9.3
Commit bed2cd540a (2023-08-24 14:43 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 12 × AMD Ryzen 5 5600H with Radeon Graphics
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, znver3)
  Threads: 1 on 12 virtual cores

Metadata

Metadata

Assignees

No one assigned

    Labels

    GCGarbage collector

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions