free() invalid next size (normal)

Hello,
There is my Integrator_Cauchy class:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
template <typename T_out,typename T_contour ,typename T_in> class C_Integrator_Cauchy: public C_Integrator{
	protected:		
	T_out (C_Integrator_Cauchy::*Integrator_ref)(T_contour * Contour,T_in * Point);
	
	C_Integrator_Cauchy(int _NumPoints, double _LimDown, double _LimUp, int _NumAps, Integrator_ID id):C_Integrator(_NumPoints, _LimDown, _LimUp, _NumAps, id){}
	
	public:
	static C_Integrator_Cauchy * createIntegrator(int _NumPoints, double _LimDown, double _LimUp, int _NumAps, Integrator_ID id ){
	    C_Integrator_Cauchy * p = 0; 
	    switch (id)
	    {
	        case qcauchyleg_lin_ID:
		    p = new C_Integrator_Cauchy(_NumPoints, _LimDown, _LimUp, _NumAps, id); 
	            p->Integrator_ref=&C_Integrator_Cauchy::qcauchyleg_lin;
	            p->setNodes(id);
	            break;       
	        default:
		    cout << "Integrator_ID Error" << endl;
	            assert( false);
	    }
	    return p;
	}
	
	T_out getResult(T_contour * Contour,T_in * Point){
		return (this->*Integrator_ref)(Contour,Point);
	}
	
	T_out qcauchyleg_lin(T_contour * Contour,T_in * Point)
	{
		T_out result(NumAps);
		T_out F(NumAps),resF(NumAps),sumF(NumAps);
		T_in N,temp,sumN,resN;
		T_in z_i,dz_i,coordin;
		for (int i = 0; i < NumAps ; i++){sumF[i] = T_in(0.0,0.0);}
		sumN = T_in(0.0,0.0);

		for (int j=1;j<=NumPoints;j++) 
		{
			temp = w[j];
			z_i=(*Contour)[0][j-1];
			dz_i=(*Contour)[1][j-1];
			coordin=(*Point);
			for (int i = 0; i < NumAps ; i++){F[i]=conj(z_i-coordin)/norm(z_i-coordin)*dz_i*(*Contour)[i+2][j-1];}
			N=conj(z_i-coordin)/norm(z_i-coordin)*dz_i;
			for (int i = 0; i < NumAps ; i++){sumF[i] += temp*F[i];}
			sumN += temp*N;
		}	
		for (int i = 0; i < NumAps ; i++){	result[i]=(sumF[i]/sumN); }
		return result;
	}
};


And the easiest main.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
typedef complex<double> dcx;

typedef vector<vector<vector<double> > > dArray3D;
typedef vector<vector<double> > dArray2D;
typedef vector<double> dArray1D;

typedef vector<vector<vector<dcx> > > dcxArray3D;
typedef vector<vector<dcx> > dcxArray2D;
typedef vector<dcx> dcxArray1D;

int main(int __argc,char *__argv[]){
	C_Integrator_Cauchy<dcxArray1D,dcxArray2D,dcx> * integ_cauchy=C_Integrator_Cauchy<dcxArray1D,dcxArray2D,dcx>::createIntegrator(2000, 0.0, 6.2831, 1, qcauchyleg_lin_ID);
	
	cout << "Start allocate something" << endl;
	dcxArray2D temp;
	temp.resize(1,dcxArray1D());
	for (int i = 0; i < 8000; i++){
		temp[0].push_back(1.0);
		cout << i << endl;
	}
	cin.get();

 return 0;
}


The issue is - after creation of the Integrator_Cauchy in main.cpp, it is impossible to allocate big vector (say i > 4000). It throws:
free() invalid next size (normal) 
although i have more than enough memory space in RAM, and the Integrator_Cauchy itself doesn't take a lot of memory.

I`m compiling on Ubuntu 12.10; g++ 4.7.2;

Any ideas?
http://jcatki.no-ip.org/fncpp/TestCase (especially points 6 and 7)

static C_Integrator_Cauchy * createIntegrator(/**/) ¿why? you are leaking memory, by the way.
Last edited on
Topic archived. No new replies allowed.