Issue 1:
This issue was experienced on Linux with the following version info and is related to issue #25884 filed by @Mistguy :

Julia Version 1.0.3

Commit 1b59908 (2019-01-15 20:28 UTC)

Platform Info:

OS: Linux (x86_64-unknown-linux-gnu)

CPU: Intel(R) Xeon(R) CPU E5-2690 v2 @ 3.00GHz

WORD_SIZE: 64

LIBM: libopenlibm

LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)

When a dictionary is created in a function or global space that has a matrix as its value, its memory never gets freed for the Linux OS kernel to use. I tested this in and out of interactive mode with the same effect.

I created the following script to test on different systems and saved it as dictAllocationTest.jl to run it as shown below:

using InteractiveUtils
versioninfo()

println()
if isinteractive()
println("Julia running in interactive mode")
else
println("Julia not running in interactive mode")
end
println()
totMem = Int64(Sys.total_memory())

println()
if isempty(ARGS)
println("Testing in global space")
else
println("Testing inside a function")
end
println()

function createTestDict(totMem)
testDict = Dict{Int64, Matrix{Float64}}()
for i in 1:100000
push!(testDict, i => ones(Float64, 100, 100))
end
mem2 = totMem - Int64(Sys.free_memory())
testDict = ()
return mem2
end

mem1 = totMem - Int64(Sys.free_memory())

if isempty(ARGS)
testDict = Dict{Int64, Matrix{Float64}}()
for i in 1:100000
push!(testDict, i => ones(Float64, 100, 100))
end
mem2 = totMem - Int64(Sys.free_memory())
testDict = ()
else
mem2 = createTestDict(totMem)
end

GC.gc()

mem3 = totMem - Int64(Sys.free_memory())

println("Memory added from dictionary is $((mem2 - mem1)/(10^9)) gigabytes")
println("Memory freed from clearing dictionary is $((mem2 - mem3)/(10^9)) gigabytes")
println("Final memory usage is $(100*mem3/mem1) % of the original")

Here are the results of testing it on linux in the global space:

> $julia1 dictAllocationTest.jl
Julia Version 1.0.3
Commit 1b5990863d (2019-01-15 20:28 UTC)
Platform Info:
OS: Linux (x86_64-unknown-linux-gnu)
CPU: Intel(R) Xeon(R) CPU E5-2690 v2 @ 3.00GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)

Julia not running in interactive mode

Testing in global space
Memory added from dictionary is 8.016703488 gigabytes
Memory freed from clearing dictionary is 0.01390592 gigabytes
Final memory usage is 161.5230175061836 % of the original

and in the function space:

> $julia1 dictAllocationTest.jl jkl
Julia Version 1.0.3
Commit 1b5990863d (2019-01-15 20:28 UTC)
Platform Info:
OS: Linux (x86_64-unknown-linux-gnu)
CPU: Intel(R) Xeon(R) CPU E5-2690 v2 @ 3.00GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)

Julia not running in interactive mode

Testing inside a function
Memory added from dictionary is 8.023105536 gigabytes
Memory freed from clearing dictionary is 0.0 gigabytes
Final memory usage is 161.65566657769227 % of the original

In both cases memory is not freed after calling GC.gc() even after the function call is completed. In contrast when I test this on macOS the results are very different:

$ $julia1 dictAllocationTest.jl
Julia Version 1.0.3
Commit 099e826241 (2018-12-18 01:34 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)

Julia not running in interactive mode

Testing in global space

Memory added from dictionary is 8.097398784 gigabytes
Memory freed from clearing dictionary is 7.736045568 gigabytes
Final memory usage is 100.62443512513228 % of the original

$ $julia1 dictAllocationTest.jl jkgf
Julia Version 1.0.3
Commit 099e826241 (2018-12-18 01:34 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)

Julia not running in interactive mode

Testing inside a function

Memory added from dictionary is 8.09453568 gigabytes
Memory freed from clearing dictionary is 7.783051264 gigabytes
Final memory usage is 100.53822059089042 % of the original

On macOS and Windows the memory is freed in both cases. It does seem however that if GC.gc() is called inside the function then memory is not freed until it is called after the function completes as I do in the script. At present I don't know how to free the memory without exiting the Julia session all together.

Issue 2:
This code takes less than a minute to fill the 64GB of my Linux machine:

julia> versioninfo()
Julia Version 1.0.3
Commit 099e826241 (2018-12-18 01:34 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-5820K CPU @ 3.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, haswell)

julia> for i in 1:100
@eval function foo()
[fill(1.0, 2_000_000) for _ in 1:100]
nothing
end
@time @eval foo()
# GC.gc() # uncomment this line to fix the issue
end

EDIT: simplified code