Hi All ,
I am facing some error in destructor in my class. Below is the constructor and destructor. Constructor seems to work fine . While the class get destructed it give the following error
*** glibc detected *** ./main: double free or corruption (fasttop): 0x08743cd0 ***
======= Backtrace: =========
/lib/libc.so.6[0xa44b16]
/lib/libc.so.6(cfree+0x90)[0xa48070]
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0x3fb731]
./main(__gxx_personality_v0+0x2e4)[0x8048984]
AND LOT OF MEMORY LOCATION
ChainMesh::ChainMesh(){
_3DarrayOfSet= new ParticleSet **[_number_of_dev];
for(int i=0;i<(int)_number_of_dev;i++)
_3DarrayOfSet[i]= new ParticleSet *[_number_of_dev];
for(int i=0;i<(int)_number_of_dev;i++)
for(int j=0;j<(int)_number_of_dev;j++)
_3DarrayOfSet[i][j] = new ParticleSet[_number_of_dev];
}
ChainMesh::~ChainMesh(){
for(int i=0;i<(int)_number_of_dev;i++){
for(int j=0;j<(int)_number_of_dev;j++){
delete [] _3DarrayOfSet[i][j];
}
}
for(int i=0;i<(int)_number_of_dev;i++)
delete [] _3DarrayOfSet[i];
delete [] _3DarrayOfSet;
}
Can any one point out any thing i am doing wrong . I am just trying to make a three dimentional array of ParticleSet object and cleaning it up after i am done.
Thanks in advance,
Shailendra