Skip to content

Why the allocated memory keep increase in for loop #49761

Closed
@crazyfireji

Description

@crazyfireji
steps = 799500:100:800000

function main(nx, ny, nz, steps, Axi, Axj, Ayi, Ayj)

    hx = 1.0/(nx - 1); hy = 1/(ny - 1);

    for n in steps
		
       
        w=rand(nx,ny,nz)
        u=rand(nx,ny,nz)
        v=rand(nx,ny,nz)
        
        Tsb = 110.4 / T_inf

        Amu =@. 1.0 / Re * (1.0 + Tsb) * sqrt(T .^ 3)/ (Tsb + Tw)

        ux, uy, uz = get_grad(u, hx, hy, Axi, Axj, Ayi, Ayj, sz)
        vx, vy, vz = get_grad(v, hx, hy, Axi, Axj, Ayi, Ayj, sz)
        wx, wy, wz = get_grad(w, hx, hy, Axi, Axj, Ayi, Ayj, sz)

        Theta = ux + vy + wz

        Sigma11 = @. (ux*2 - 2/3*Theta) * Amu
        Sigma22 = @. (vy*2 - 2/3*Theta) * Amu
        Sigma33 = @. (wz*2 - 2/3*Theta) * Amu
        Sigma12 = @. (uy + vx) * Amu
        Sigma23 = @. (vz + wy) * Amu
        Sigma13 = @. (uz + wx) * Amu

        println("Write OCFD$(string(n,pad=7)).jld2")
				
        jldopen("$(filepath1)test$(string(n,pad=7))_sigma_theta.jld2","w") do f
            f["σ11"] = Sigma11
            f["σ22"] = Sigma22
            f["σ33"] = Sigma33
            f["σ12"] = Sigma12
            f["σ13"] = Sigma13
            f["σ23"] = Sigma23
            f["θ"] = Theta
        end
    end

end


@time main( nx, ny, nz, steps, Axi, Axj, Ayi, Ayj)

The memory allocated by Julia will keep increase in for loop. How to solve it, only by gc() manually? This fig shows the memory allocated when run this Julia code.
536fec9f26a3c3c4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions