Sorry, I meant allocation not leak.
On Friday, September 4, 2015 at 9:56:48 AM UTC-4, Arch Call wrote:
>
> I am have difficulty in firguring out why WhyMemoryLeak() leaks memory,
> and NoMemoryLeak() does not!!
> They are both identical except for the line in the for loop.
>
> It is driving me nuts!
>
> I am running Julia 3.11 and Windows 10. This happens in Juno and in the
> REPL.
>
> Does anyone have any ideas?
>
> Thanks...Archie
>
>
> #------------------------ sample Julia Program
> function WhyMemoryLeak(num_iters::Int64, sleep_time::Float64)
> for i = 1:num_iters
> sleep(sleep_time)
> end
> return nothing
> end
>
> function NoMemoryLeak(num_iters::Int64, sleep_time::Float64)
> for i = 1:num_iters
> sqrt(i) * sleep_time
> end
> return nothing
> end
>
> #--------- simulate the actual sleep_ns process computing actual sleep
> times ----------
> sleep_time = .003
> println("-- results for NoMemoryLeak --")
> @time NoMemoryLeak(10, sleep_time) #-- warm up NoMemoryLeak
> @time NoMemoryLeak(100, sleep_time) #-- run NoMemoryLeak with 100 iters
> @time NoMemoryLeak(1000, sleep_time) #-- run NoMemoryLeak with 1000 iters
>
>
> println("\n-- results for NoMemoryLeak --")
> @time WhyMemoryLeak(10, sleep_time) #-- warm up WhyMemoryLeak
> @time WhyMemoryLeak(100, sleep_time) #-- run WhyMemoryLead with 100 iters
> @time WhyMemoryLeak(1000, sleep_time) #-- run WhyMemoryLead with 100 iters
>
> #---- results of run
>
> -
>
> -- results for NoMemoryLeak --
>
> -
>
> elapsed time: 0.004308194 seconds (72968 bytes allocated)
>
> -
>
> elapsed time: 4.521e-6 seconds (80 bytes allocated)
>
> -
>
> elapsed time: 4.931e-6 seconds (80 bytes allocated)
>
> -- results for NoMemoryLeak --
>
> -
>
> elapsed time: 0.048005713 seconds (70748 bytes allocated)
>
> -
>
> elapsed time: 0.431385715 seconds (39280 bytes allocated)
>
> -
>
> elapsed time: 4.346366676 seconds (392080 bytes allocated)
>
>
>
>