Skip to content

Commit

Permalink
[julia/io_leak] "memory leak" in the young gen. JuliaLang/julia#11814
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed Jul 30, 2015
1 parent 98f72f3 commit 7c1ce27
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions julia/io_leak/io_leak.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/julia -f

close2(s) = nothing

function f1(n)
for i in 1:n
s = zeros(UInt8, 152)
finalizer(s, close2)
# gc()
# finalize(s)
i % 10000 == 0 && println(i)
end
end
# f1(6000_000)

@eval type A
$([symbol("a$i") for i in 1:100]...)
A() = new()
end

type B
a::A
end

function f2(n)
for i in 1:n
s = B(A())
finalizer(s, close2)
# gc()
# finalize(s)
i % 10000 == 0 && (println(i); gc())
end
end

function f3(n)
for i in 1:n
s = A()
finalizer(s, close2)
# gc()
# finalize(s)
i % 10000 == 0 && (println(i); gc())
end
end

f2(6000_000)

sleep(3)

0 comments on commit 7c1ce27

Please sign in to comment.