vector size limit

Oct 8, 2012 at 2:53am
I am getting a St9bad_alloc error when trying to allocate a std::vector<uint8_t> of size:

 
std::vector<uint8_t> myVector(96*3*320*240*100);


I calculated this to only be ~2GB yet the machine I'm working on has 32GB of RAM. Is there a limit on the size of std::vectors? If so, is there a way to change it?

Thanks!
Oct 8, 2012 at 4:21am
It's probably not an issue so much of available memory as it is available contiguous memory, which vector requires.

When trying to allocate that much memory in one clump, you're kind of rolling the dice. Even if you could up the max on your machine (which I'm not sure you can), there's no way to know whether it will work on someone else's machine.


The question I have to ask is why in the world do you need such a large vector?
Oct 8, 2012 at 5:01am
zo'o solving the heat equation.

¿Shouldn't pagination relax that constraint?
Oct 8, 2012 at 5:19am

The question I have to ask is why in the world do you need such a large vector?


Haha, its for some large scale machine learning. I'm loading a file with 96,000 images, each 3x320x240 pixels. I suppose I could just split up the array between images.

Thanks again.
Topic archived. No new replies allowed.