Hello,
I've been having a problem for quite a while, the problem started when I was coding a program few months ago, whenever I attempt to use the delete operator to delete dynamically allocated objects using new operator, an error message appears, the message says:
Microsoft Visual C++ Debug Library
Debug Error!
Program: .....
Module:
File: i386\chkesp.c
Line: 42
The value of ESP was not properly saved after a function call. This is usually the result of calling a function with one calling convention with a function pointer declared with a different calling convention.
I removed the delete operator, and the program worked well except for the memory leaks, and now, I'm having the same problem all over again, I'm coding a new program, and the same is hapenning again, would you tell me what is the problem please?!
the code where I delete the object is:
void CRegression::Replace(CChromosome new_chrom)
{
int index = 0;
for (int i = 1; i < POPULATION_SIZE; i++)
{
if (Population->GetQuality() <Population[index]->GetQuality())
index = i;
}
delete Population;
Population = & new_chrom;
}
and the code where I creaye the new object is:
CRegression::CRegression()
{
for (int i =0; i < POPULATION_SIZE; i++)
{
Population = new CChromosome();
Population->CreateRandom();
}
}
Thanks
Sincerely
Nawaf Arhamah
I've been having a problem for quite a while, the problem started when I was coding a program few months ago, whenever I attempt to use the delete operator to delete dynamically allocated objects using new operator, an error message appears, the message says:
Microsoft Visual C++ Debug Library
Debug Error!
Program: .....
Module:
File: i386\chkesp.c
Line: 42
The value of ESP was not properly saved after a function call. This is usually the result of calling a function with one calling convention with a function pointer declared with a different calling convention.
I removed the delete operator, and the program worked well except for the memory leaks, and now, I'm having the same problem all over again, I'm coding a new program, and the same is hapenning again, would you tell me what is the problem please?!
the code where I delete the object is:
void CRegression::Replace(CChromosome new_chrom)
{
int index = 0;
for (int i = 1; i < POPULATION_SIZE; i++)
{
if (Population->GetQuality() <Population[index]->GetQuality())
index = i;
}
delete Population;
Population = & new_chrom;
}
and the code where I creaye the new object is:
CRegression::CRegression()
{
for (int i =0; i < POPULATION_SIZE; i++)
{
Population = new CChromosome();
Population->CreateRandom();
}
}
Thanks
Sincerely
Nawaf Arhamah