Skip to content

Garbage collection of SharedArrays #27070

@usefulhyun

Description

@usefulhyun

Hi, there

I think that automatic garbage collection does not work for SharedArray Datatype.
Only explicit calling gc function deallocate SharedArrays that are useless.

What I am using version 0.6.2
The below code works well.

function main()
sz = 10000

for i=1:100
    sm = SharedMatrix{Float64}(sz, sz)
    # SharedMatrix is not allocated before they use.
    # So explicit access is required to make them being allocated.
    for x=1:sz
        for y=1:sz
            sm[x,y] = i
        end
    end
    println(i, " ", sm[1,1])
    gc()
end
end # main
main()

However, the below code makes a crash.

function main()
sz = 10000

for i=1:100
    sm = SharedMatrix{Float64}(sz, sz)
    for x=1:sz 
        for y=1:sz
            sm[x,y] = i
        end
    end
    println(i, " ", sm[1,1])
    #gc() without explicit gc() call.
end
end # main
main()

The reason of this crash is the limitation of allocating shared memory.

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