Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
236 views
in Technique[技术] by (71.8m points)

Under what circumstances would Julia allocate memory to single digits?

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...