Over the past few months, I have been working on a Visual C ++ project to take pictures from cameras and process them. Until today, it took about 65 ms to update the data, but now it has increased dramatically. What happens: I run my program, and for the first 30 or so iterations, it runs as expected, and then the cycle time increases from 65 ms to 250 ms.
It is odd that after each function, I found out that the part of the code causing the slowdown is quite simple and has not been changed in a month. The data that enters it remains unchanged and identical for each iteration, but the execution time, which is initially less than 1 ms, suddenly increases to 170 ms, while the rest of the code still works as expected (in time).
Basically, I call the same function again and again, for the first 30 calls it makes, as it should, after that it slows down for no apparent reason. It may also be worth noting that this is a sudden change in runtime, not a gradual increase.
What could be the reason for this? The code skips some memory (~ 50 kbps), but not enough to guarantee a sudden 4x slowdown. If anyone has any ideas, I would love to hear them!
Edit: Wow, that was fast! Here's the code (minus some math) that slows down. I know that this is a function in which the computational time will increase rapidly if you increase the number of lines. The key here is that with the same data, it slows down after 30 iterations.
void CameraManager::IntersectLines()
{
TMaths maths;
TLine line1, line2;
while(lines.size()>0)
{
line1 = lines[0];
lines.erase(lines.begin());
CvMat* aPoint;
for (int i = 0; i<lines.size(); i++)
{
line2 = lines[i];
aPoint = cvCreateMat(1, 4, CV_32FC1);
maths.Intersect(line1.xyz, line2.xyz, line1.uvw, line2.uvw, aPoint);
points.push_back(aPoint);
}
}
}
}