Memory allocation tracking

#1

I used --track-allocation to see the memory allocated to the code and I got below results for one of the function. I am just allocating a value from an array to the variable and it shows a large number as the memory allocation. Is there anything wrong with my code> Thank you.

- function solver(dx, dy, nx, ny, residual, source, u_numerical, rms,
        -                 initial_rms, maximum_iterations, tiny, lambda, output, flag,
        -                 relaxcount)
        - 
290003364     flag_solver     = flag[2]
        0     flag_multigrid  = flag[3]
        0     flag_order      = flag[6]
        - 
        0     if flag_multigrid == 1 && flag_order == 1
        -         # flag_solver     = flag[2]
        0         if flag_solver == 1
        -         # call jacobi solver
        0             jacobi_solver(dx, dy, nx, ny, residual, source, u_numerical, rms,
        -                           initial_rms, maximum_iterations, lambda, output)
        0         elseif flag_solver == 2
        -         # call gauss seidel solver
        0             gauss_seidel(dx, dy, nx, ny, residual, source, u_numerical, rms,
        -                          initial_rms, maximum_iterations, lambda, output)
        0         elseif flag_solver == 3
        -         # call steepest descent solver
        0             steepest_descent(dx, dy, nx, ny, residual, source, u_numerical, rms,
        -                              initial_rms, maximum_iterations, tiny, lambda, output)
        0         elseif flag_solver == 4
        -         # call conjugate gradient solver
        0             conjugate_gradient(dx, dy, nx, ny, residual, source, u_numerical, rms,
        -                                initial_rms, maximum_iterations, tiny, lambda, output)
        -         else
        0             biconjugate_gradient_stab(dx, dy, nx, ny, residual, source, u_numerical,
        -                                       rms, initial_rms, maximum_iterations, tiny, lambda, output)
        -         end
        -  end
0 Likes

#2

Large allocations on the very first line in the function typically means the allocation had to do with the calling of the function.

1 Like

#3

Does the function call requires large memory allocation? What are the ways to reduce the memory allocation for the function call? Thank you.

0 Likes

#4

If things are not type stable then it can require some memory to call. Best is if you can make a small example that exhibits the problem.

1 Like