Posted: 09 Jun 2015, 01:44
im facing a ram increase pb i fail to solve,
it's in a synth code ,in some part od the code it looks like each time a new buffer is created it adds to memory with no release, until reaching limits and crash.
i tried to use 'delete' operator both with [] or not , but it doesn't semm to do something
.a bit stucked from a while.. any ideas?
the code is very wide but it seems this isolated part seemms to be the problem:
(to summup it's an up-scaling array function to process on lows sizes array in order trying to save some cpu then re-stretch.
it's in a synth code ,in some part od the code it looks like each time a new buffer is created it adds to memory with no release, until reaching limits and crash.
i tried to use 'delete' operator both with [] or not , but it doesn't semm to do something
the code is very wide but it seems this isolated part seemms to be the problem:
(to summup it's an up-scaling array function to process on lows sizes array in order trying to save some cpu then re-stretch.
Code: Select all
//////
.....
double* S1_HI = new double[SMP_DUR_LOW * reduxa];
.....
S1_HI = UPSCALE_16X(S1_LOW, SMP_DUR_LOW); // <---------- memory increase stops when bypassing
......
delete[] S1_HI;
S1_HI = nullptr;
// this calls those functions:
//////////////////////////////////////////////////////
double* BEZIER_MULTI::UPSCALE_2X(double *Input,int sizein)
{
int sizeOut = sizein * 2;
double* TMP_OUT = new double[sizeOut];
double valin;
int j;
for (int i = 0; i < sizein; i++)
{
j = i * 2;
valin = Input[i];
TMP_OUT[j] = valin;
if (i < (sizein-1 ))
{
TMP_OUT[j + 1] = (valin + Input[i+1]) / 2;
}
else
{
TMP_OUT[j + 1] = valin +((valin - Input[i - 1]) / 2);
}
}
return TMP_OUT;
delete TMP_OUT;
TMP_OUT = nullptr;
}
//////////////////////////////////////////////////////////////
double* BEZIER_MULTI::UPSCALE_4X(double *Input, int sizein)
{
int sizeOut = sizein * 4;
double* TMPb_OUT = new double[sizeOut];
TMPb_OUT = UPSCALE_2X(UPSCALE_2X(Input, sizein),sizein*2);
return TMPb_OUT;
delete TMPb_OUT;
TMPb_OUT = nullptr;
}
/////////////////////////////////////////////////////////////////
double* BEZIER_MULTI::UPSCALE_8X(double *Input, int sizein)
{
int sizeOut = sizein * 8;
double* TMPc_OUT = new double[sizeOut];
TMPc_OUT = UPSCALE_4X(UPSCALE_2X(Input, sizein), sizein * 2);
return TMPc_OUT;
delete TMPc_OUT;
TMPc_OUT = nullptr;
}
//////////////////////////////////////////////////////////////////
double* BEZIER_MULTI::UPSCALE_16X(double *Input, int sizein)
{
int sizeOut = sizein * 16;
double* TMPd_OUT = new double[sizeOut];
TMPd_OUT = UPSCALE_4X(UPSCALE_4X(Input, sizein), sizein * 4);
return TMPd_OUT;
delete TMPd_OUT;
TMPd_OUT = nullptr;
}
////////////////////////////////////////////////////////