memory - C++ calling one function repeatedly system hang -
i getting serious issue 1 function in c++. function
double** fun1(unsigned l,unsigned n, vector<int>& list, vector<string>& dataarray) { double** array2d = 0; array2d = new double*[l]; string alphabet="acgt"; (int = 0; < l; i++) { array2d[i] = new double [4]; vector<double> count(4, 0.0); for(int j=0;j<n;++j) { for(int k=0;k<4;k++) { if (toupper(dataarray[list[j]][i])==alphabet[k]) count[k]=count[k]+1; } } for(int k=0;k<4;k++) array2d[i][k]=count[k]; count.clear(); } return array2d; }
the value of l around 100 , n=1, dataarray size (50000 x l) , list contain 1 number between 0-49999. calling function main program many number of times (may more 50 million times). upto number of times going smooth after 2/3 minute around system hangs. unable find problem code. guess memory getting short don't know why?
you missing corresponding delete[]
code.
note []
means deleting array. if forget add these venturing undefined territory (3.7.4.2 in n3797).
you may wish try using std::array
mitigate having new
, delete[]
much. if called as , loop small concerned coherency of data.
Comments
Post a Comment