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!

5
  • 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? Commented Feb 14, 2016 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. Commented Feb 14, 2016 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? Commented Feb 14, 2016 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 datascience.stackexchange.com/questions/tagged/bigdata Perhaps you can search/ask questions there and here to get closer to your solution Commented Feb 14, 2016 at 17:01
  • @JosephYoung, Thank you for the help, I will do that! Commented Feb 14, 2016 at 17:02

1 Answer 1

1

RAM Memory exceeded.

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.