Error using zeros Requested 501950x501950 (1877.2GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for mo

4 views (last 30 days)
Error using zeros
Requested 501950x501950 (1877.2GB) array exceeds maximum array size preferencearray exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for
more information,
Please tell me how to resovle this issue
thanks

Answers (1)

John D'Errico
John D'Errico on 17 Mar 2019
Edited: John D'Errico on 17 Mar 2019
How to resolve it?
  • Don't try to create an array that large.
  • Buy a seriously larger computer.
  • Invest in a large, fast hard disk, and then sit down, and start on your plan to read all the books in the Library of Congress. (It won't take that long though.)
  • Find a job at the NSA, or some other place where sufficiently large computers are a dime a dozen.
  • Learn what are sparse matrices, why and when you might use them, and HOW to use them properly.
  • Learn to use other data types. Thus a single array of that size would only take half the memory, and a uint8 array would take 1/8 of the memory, a relative pittance.
  • Buy stock in Starbucks, as you will be drinking a lot of coffee.
  • Rent time on a super computer.
  • Decide in the future to solve problems of a managable size.
  • Speaking of the future, build a time machine, travel to the future, to a time when Moore's law will see everyone has computers that large.
  • Find way to travel at very near the speed of light, so that time dilation will effectively allow you to return to Earth in the future, thus an effective time machine. A good feature of this idea is it will let you visit several nearby stars during your trip.
  • Buy many around the world plane tickets, so that you will be crossing the international date line, so traveling forward in time by one day each time you do so. Eventually, you will have traveled to the far future, when computers capable of solving your problem will be again commonplace. (There might be a bug in this idea, but it seems like it should work. In fact, it was described by none less than Mark Twain in his book, "Following the Equator". I'll tell you in a few days when I get back from my own world trips.)
  • Learn to use zeros properly, thus, reading the help for the function zeros.
The fact is, you apparently tried to create an array of that size. We don't know why. No hints were provided by you.
So some or all of those answers might be appropriate, or perhaps some linear combination of them all. I could probably come up with others too. If you truly want serious help, I recommend reading the help for zeros. Or, at least, showing how you called zeros, and explaining why it is that you think you needed to create an array of that size. Then reconsider if you really needed/wanted to do that.
One possibility is you did not intend to create an array that large. So don't do it. What else can anyone say?
Ok, perhaps, maybe, you were hoping to create a vector of length 501950, so an array of size 501950x1, and you thought that the call
zeros(501950)
would have done as you wish. This is why several of my comments were directed at reading the help for zeros, since zeros(501950) actually tries to create a SQUARE array of that size, so 501950x501950.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!