Skip to content

Memory Leak: GC does not deallocate values allocated while it was turned off, unless specifically requested #45068

@Clemapfel

Description

@Clemapfel

Hi, the following is a memory leak:

x = 1234
while (true)
    GC.enable(false)
    x = rand()
    GC.enable(true)
    #GC.collect(GC.GC_AUTO)
end

This slowly fills up the RAM until the OS kills the process. With #GC.collect(GC.GC_AUTO) commented in, this code behaves as expected. Without any of the GC. calls, no memory leak occurs either.

Clearly the GC is still updating the roots, otherwise GC.collect would have no effect. For some reason, the unused rand() values are never deallocated. This same behavior is exhibited if implementing the above using the C-API.

Tested on Julia 1.7.2, on Ubuntu 20.04.2 LTS, 64-bit, but I've asked a few people, and they all reproduced it.

I also opened a discourse thread about this

Metadata

Metadata

Assignees

Labels

GCGarbage collectorbugIndicates an unexpected problem or unintended behavior

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions