Ok, I've slimmed a lot the original code...
Within Excel, I run the dll about 30000 times and I notice a steady increase in the memory allocation of excel (from Task Manager). How can I avoid this problem?
I suppose that, as soon as the dll has been terminated, the used memory is released, but it seems not to be the case...
Code:
void _stdcall AreaComputation (double *x,double *y,float omega,double *area,double *volume)
{
double tarea=0.0,tvolume=0.0;
int i;
int ns=19;
int n=(ns-1)/2;
double *ra=new double[ns];
double *ha=new double[ns];
for(i=0;i<n;i++)
{
ha[i]=x[i];
ra[i]=y[i];
ha[ns-i-2]=-x[i];
ra[ns-i-2]=y[i];
}
ha[ns-1]=ha[0];
ra[ns-1]=ra[0];
double Cy=0.0;
double pi=3.1415926535897;
omega=omega*pi/30.0;
for(i=0;i<ns-1;i++)
{
tarea=tarea+(ha[i]*ra[i+1]-ha[i+1]*ra[i]);
Cy=Cy+(ra[i]+ra[i+1])*(ha[i]*ra[i+1]-ha[i+1]*ra[i]);
}
tarea=tarea/2;
Cy=Cy/6/tarea;
tvolume=tarea*2*pi*Cy;
double *dummy;
dummy=&tarea;
*area=*dummy;
dummy=&tvolume;
*volume=*dummy;
delete [] ra,ha;
ra=NULL;
ha=NULL;
dummy=NULL;
}