# Memory allocation tracking

**URL:** https://discourse.julialang.org/t/memory-allocation-tracking/21597
**Category:** General Usage
**Created:** [March 7, 2019, 8:20pm UTC](https://discourse.julialang.org/t/memory-allocation-tracking/21597 "2019-03-07T20:20:44Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Suraj\_Pawar](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@Suraj\_Pawar](https://discourse.julialang.org/u/Suraj_Pawar)
#### Post date: [March 7, 2019, 8:20pm UTC](https://discourse.julialang.org/t/memory-allocation-tracking/21597/1 "2019-03-07T20:20:44Z")

</div>

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.

```julia
- 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

```

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [March 7, 2019, 9:32pm UTC](https://discourse.julialang.org/t/memory-allocation-tracking/21597/2 "2019-03-07T21:32:46Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Suraj\_Pawar](https://avatars.discourse-cdn.com/v4/letter/s/aca169/32.png) [@Suraj\_Pawar](https://discourse.julialang.org/u/Suraj_Pawar)
#### Post date: [March 8, 2019, 12:31am UTC](https://discourse.julialang.org/t/memory-allocation-tracking/21597/3 "2019-03-08T00:31:05Z")

</div>

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

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [March 8, 2019, 10:16am UTC](https://discourse.julialang.org/t/memory-allocation-tracking/21597/4 "2019-03-08T10:16:46Z")

</div>

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.
