Let’s look at this example first:

```
julia> using BenchmarkTools
julia>
julia> function f(x::Matrix{Float64})
y = x * x
return nothing
end
f (generic function with 1 method)
julia>
julia> a = rand(4,4)
4×4 Matrix{Float64}:
0.267034 0.604533 0.810068 0.0177578
0.498969 0.358759 0.515774 0.246705
0.791061 0.493207 0.843597 0.0925471
0.706005 0.702466 0.414509 0.150272
julia>
julia> @btime begin
f(a)
end
156.121 ns (1 allocation: 192 bytes)
julia>
julia> @btime begin
f(a)
f(a)
end
310.246 ns (2 allocations: 384 bytes)
julia>
julia> @btime begin
f(a)
f(a)
f(a)
end
465.306 ns (3 allocations: 576 bytes)
```

For the last one, its peak memory consumption should equal 192 bytes, not triple. I don’t know if my example is appropriate, but I think you get the idea, I want to know if there’s a function that can gives the peak memory consumption.

```
julia> @time begin
f(a)
f(a)
f(a)
end
0.000008 seconds (3 allocations: 576 bytes)
julia> @allocated begin
f(a)
f(a)
f(a)
end
576
```

Neither can these two.