Out of memory and new computer
1 view (last 30 days)
Show older comments
Hello forum, I have to re-run a simulation that requires to create very large arrays (up to 160.000.000 elements) but with my actual computer I got the error "out of memory". Of course, I think it is due to the CPU (AMS A4) and the ram (4 gb). I run this simulation, the first time, on a very powerful computer (i7 and 64gb of ram) but it is something I can not afford. So I am thinking to buy (or rent) a new computer, but I would know which technical specifications are required, in order to not buy something useless. Can you help me to estimate which CPU and how much ram I need in order to do this? Sorry for my bad language and thanks in advance.
8 Comments
David Goodmanson
on 3 Jun 2018
Edited: David Goodmanson
on 3 Jun 2018
Hi Allesandro,
It's not hard to figure out how much memory is required just for the variables. Assuming t,u1,u2,y1,y2 are all the same size and you are storing double precision 64 bit numbers, 5 * 1.6e8 * 8 = 6.4 gB. Of course you have to have more than that to give Matlab space to work. Add on system requirements and that puts you up in the 10 gB range. If possible, the most direct and probably cheapest way to go would be to add more memory to the computer you have. New vs. old CPU, that is not much of a factor.
Greg
on 3 Jun 2018
MATLAB Online crashes in spectacular form when I try:
a = randi(10,1.6e8,2); % So not enough for Alessandro
Simply calculating variable size is not a good answer, especially when talking about spending money on a tight budget. Run the profiler in memory mode to see how much RAM the whole codebase actually uses:
profile on -memory
% Run your code here
profile off
profile viewer
However, I still don't recommend making a purchase based on one codebase. What happens when the requirements go up to 1.8e8 elements?
Do more research into tall arrays as initially recommended. These are designed for exactly what you're experiencing. It is not a simple command you just put at the top of existing code; you will have to learn to modify the code to properly utilize tall.
Finally, since tall essentially just uses hard drive storage as RAM, there would be little difference from pagefile in your case. Try going into system settings and cranking up your pagefile size. Note, things will run much slower on HDD (or even SSD) than RAM.
Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!