# Help: OutOfMemoryError()

Hi I am new to still new to Julia and I have encountered this error and I cant figure out what is causing it and why.
Below is my code. The first time I ran this, it was executed fine but after that I keep getting this out of memory error.

``````function logistic_dot(x,beta ,alpha = 0)
return @. 1.0/(1.0+exp((beta*x) + alpha))
end

temperature = challenger_data_new[:,1]
D = challenger_data_new[:,2]

@model function challenger(data,temperature)   #Turing model for challenger data info
β ~ Normal(0,10)
α ~ Normal(0,10)
p = @. 1/(1+exp((temperature*β)+α))  # p(t)= 1/(1+eᵝᵗ⁺ᵅ)
for i in eachindex(p)
data[i] ~ Bernoulli(p[i])
end
return p
end

model = challenger(D,temperature)
map_estimate = optimize(model, MAP())
trace = sample(model,MH(),1000000, init_theta = map_estimate.values.array)

β_samples = trace[:β];
α_samples = trace[:α];

t = LinRange(minimum(temperature) -5,maximum(temperature)+5,50)
p_t = logistic_dot(transpose(t),β_samples,α_samples)
mean_prob_t = mean(p_t,dims = 1)[:]

``````

The issue seems to be with the logistic_dot function

Could you post the complete error message?

Stacktrace:
 Array
@ .\boot.jl:450 [inlined]
 Array
@ .\boot.jl:458 [inlined]
 Array
@ .\boot.jl:465 [inlined]
 similar
@ .\abstractarray.jl:785 [inlined]
 similar
@ .\abstractarray.jl:784 [inlined]
 similar
 similar
 copy
 materialize
 logistic_dot(x::LinearAlgebra.Transpose{Float64, LinRange{Float64}}, beta::AxisArrays.AxisArray{Float64, 2, Matrix{Float64}, Tuple{AxisArrays.Axis{:iter, StepRange{Int32, Int32}}, AxisArrays.Axis{:chain, UnitRange{Int32}}}}, alpha::AxisArrays.AxisArray{Float64, 2, Matrix{Float64}, Tuple{AxisArrays.Axis{:iter, StepRange{Int32, Int32}}, AxisArrays.Axis{:chain, UnitRange{Int32}}}})
@ Main c:\Users\ohian\OneDrive - University of Strathclyde\Documents\Julia Files\Bayesian Methods\Chapter2\Challenger_Spac_ Shuttle_Disaster_Example.jl:36
 top-level scope
@ c:\Users\ohian\OneDrive - University of Strathclyde\Documents\Julia Files\Bayesian Methods\Chapter2\Challenger_Spac_ Shuttle_Disaster_Example.jl:91
in expression starting at c:\Users\Julia Files\Bayesian Methods\Chapter2\Challenger_Spac_ Shuttle_Disaster_Example.jl:91

You’re trying to sample 1 million vectors with dimension `size(challenger_data_new,1)`, and I guess you computer doesn’t have enough memory to store that result (that’s what `OutOfMemoryError` means). You either need to reduce the number of samples or get a bigger computer 2 Likes

Thank you!

Guess I must keep that in mind when sampling until i get a better PC. 1 Like

the other answer is that this code could probably be written to not allocate nearly as much as it currently does.

Could you please elaborate on this?
I am still new to Julia and I’m currently following a Turing tutorial as a basis for this code