Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ vector out of memory

I have a very large vector (millions of entries 1024 bytes each). I am exceeding the maximum size of the vector (getting a bad memory alloc exception). I am doing a recursive operation over the vector of items which requires accessing other elements in the vector. The operations need to be done quickly. I am trying to avoid writing to disk for speed reasons. Is there any other way to store this data that would not require writing to disk? If I have to write the data to disk, what would be the most ideal way to do it>

edit for a few more details.

The operations that I am performing on the data set is generating a string recursively based on other data points in the vector. The data is sorted when it is read in. Data sets ranging from 50,000 to 50,000,0000.

like image 308
user2174896 Avatar asked Mar 15 '13 17:03

user2174896


1 Answers

The easiest way to solve this problem is to use STXXL. It's a reimplementation of the STL for large structures that transparently writes to disk when the data won't fit in memory.

like image 81
Dirk Holsopple Avatar answered Sep 28 '22 05:09

Dirk Holsopple