Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Meet and Greet (http://www.go4expert.com/community/meet-and-greet/)
-   -   std::bad_alloc (http://www.go4expert.com/community/stdbadalloc-t26211/)

SADS 5Jul2011 06:17

std::bad_alloc
 
Hi friends,

I wrote a code to build a matrix with specific calculations. When I'm using 3000 elements works well ... But I did a test with 150.000 (150.000 x 150.000) and I had problems.

" terminate called after throwing an instance of 'std::bad_alloc' "


I'm copying the code part of the problem:



void buildMatrix(ofstream &myfileOutSubsetZ, ofstream &myfileOutSubset,ofstream &myfileOut,ofstream &myfileLog,vector<string> &vetorInd)
{
float **AAA = 0;
AAA = new float *[vetorInd.size()];
for(int i=0;i<vetorInd.size();i++)
AAA[i]= new float [vetorInd.size()]; // PROBLEM!
...
I captured the exception:

"St9bad_alloc".

Can you help me please?


All times are GMT +5.5. The time now is 19:23.