I have written a recursive function for getting objects in larger arrays in julia. The following error occured:
ERROR: LoadError: StackOverflowError:
in cat_t at abstractarray.jl:831
in recGetObjChar at /home/user/Desktop/program.jl:1046
in recGetObjChar at /home/user/Desktop/program.jl:1075 (repeats 9179 times)
in getImChars at /home/user/Desktop/program.jl:968
in main at /home/user/Desktop/program.jl:69
in include at ./boot.jl:261
in include_from_node1 at ./loading.jl:304
in process_options at ./client.jl:308
in _start at ./client.jl:411
while loading /home/user/Desktop/program.jl, in expression starting on line 78
If you want to have a look at the code, I have already opened an issue (Assertion failed, process aborted). After debugging my code for julia v 0.4, it is more obvious, what causes the problem. The tupel locObj gets much bigger than 9000 entries, because one object can be e.g. 150 x 150 big. That would result in a length of 22500 for locObj. How big can tupels get, and how can I avoid a stackoverflow? Is there another way to save my values?
As it's commented, I think better approaches exist to work with big arrays of data, and this answer is mainly belongs to this part of your question:
I have prepared a test to show how using
mmap
is helpful when dealing with big array of data, following functions both do the same thing: they create a vector of 3*10E6float64
, then fill it, calculatesum
and print result, in the first one (mmaptest()
), a memory-map structure have been used to storeVector{Float64}
while second one (ramtest()
) do the work on machine ram:then both functions have been called and memory allocation size was calculated:
It's obvious from those tests that with a memory-map object, memory allocation is much smaller.
as it's clear from @time test, using
mmap
makes the code slower while needs less memory.I wish it helps you, regards.