Hi All,
I do some ensemble averaging calculation that requires me to accumulate
very many distributions which I store in arrays. Basically something like
class AdaptiveNW{
public:
int** getDegreeDistri bution();
.......
}
AdaptiveNW::get DegreeDistribut ion(){
int* CN= new int[10000];
int* ErrN=new int[10000];
int** res = new int* [2];
..........
res[0]=CN;
res[1]=ErrN;
return res;
}
........
AdaptiveNW *anw;
int **accArray;
for(i=0; i<10000; i++){
anw = new AdaptiveNW();
accArray=anw->getDegreeDistr ibution();
.......//adding up accArrays
delete []accArray;
delete anw;
}
......
nonetheless my memory usage increases steadily. How do I free the memory
occupied by the return arrays correctly?
Thanks, Oliver
I do some ensemble averaging calculation that requires me to accumulate
very many distributions which I store in arrays. Basically something like
class AdaptiveNW{
public:
int** getDegreeDistri bution();
.......
}
AdaptiveNW::get DegreeDistribut ion(){
int* CN= new int[10000];
int* ErrN=new int[10000];
int** res = new int* [2];
..........
res[0]=CN;
res[1]=ErrN;
return res;
}
........
AdaptiveNW *anw;
int **accArray;
for(i=0; i<10000; i++){
anw = new AdaptiveNW();
accArray=anw->getDegreeDistr ibution();
.......//adding up accArrays
delete []accArray;
delete anw;
}
......
nonetheless my memory usage increases steadily. How do I free the memory
occupied by the return arrays correctly?
Thanks, Oliver
Comment