Suppose I write this function
function test_function(T)
c = 1
d = 31
q = 321
b = 32121
a = 10
for i in 1:T
c = d + q + b + a
end
end
There will be no memory allocation. However, in my own code, I wrote a similar loop, but I encounter a huge amount of memory allocation. I can't share the entirety of my code, but when I used --track-allocation=user
, I see the following results
80000 q = 3
- p = 0.1
- p_2 = 3
- q_2 = .2
-
240000 r = p - p_2 + q_2 - q;
The code above is in a for loop. This is just strange to me - why would Julia ever allocate memory to single digits?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…