0

I am writing a program to test a feature. However, I get an error when I declare a boost::multi_array that has a certain size. I get the following error:

terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc

My code looks like this:

#include <boost/multi_array.hpp>
#include <boost/array.hpp>
boost::multi_array<double,3> test ;
test.resize( boost::extents[1000][1000][1000] ) ;

I get don't get the error if I declare a 2D multi_array or if I declare a 3D multi_array with a size of 10x10x10 and 100x100x100.

Does anyone has any idea to fix this? Is this problem compiler related or something?

I executed the code using Qt creator and I use the MinGW compiler.

Later in my project I will use arrays with a dimension of 12/13 and each dimension will have a length between 100 and 1000, so I really need this to work.

Thanks in advance!

Rene
  • 41
  • 4
  • Just from doing quick math, (I have no idea how the language/libraries work), a 1000x1000x1000 array of doubles is 8 gigabytes. You say you use 12/13 dimension arrays, have you actually tried this? – Joseph Young Feb 14 '16 at 16:46
  • 1
    12 dimensions with a length of 100 each will require 8 yottabyte of RAM. Looks like you need to rethink your design. – Baum mit Augen Feb 14 '16 at 16:48
  • @JosephYoung Thanks for the comments. I am a bit knew to the big data simulations, so I guess I need to think the design through. Probably I will write the data during my simulations. This means that, basically, my RAM memory was not enough to perform this simulation. Do you have any ideas about big data management? Or links to learn something about it? – Rene Feb 14 '16 at 16:53
  • @Rene I probably wont be of much help as I've never ventured into anything close to big data, but I suppose it depends entirely on what you want to do with said data. There is a data science community which has a topic on big data http://datascience.stackexchange.com/questions/tagged/bigdata Perhaps you can search/ask questions there and here to get closer to your solution – Joseph Young Feb 14 '16 at 17:01
  • @JosephYoung, Thank you for the help, I will do that! – Rene Feb 14 '16 at 17:02

1 Answers1

1

RAM Memory exceeded.

double takes up 8 bytes -> 1000x1000x1000 doubles = 8 gigabytes of required RAM.

Rene
  • 41
  • 4