Today I ran into the most weird performance problem/bug I ever encountered:
My program conists of 3 main blocks of code. At the end of block 1 there is a function that does some math (pure integer, nothing special). For some reason that code turned out to be 10 times slower if I execute the other two main blocks of code afterwards. Without executing those other two block (after block 1 finished...) it runs at top performance.
Lots of debugging, benchmarking and testing reveiled that the problem was related to using an STL vector object (on the stack and only in that one function). I changed my code to use an old-school static array and the problem was gone. Yet, simply introducing the vector again into that function and just adding three integers brings the performance down again.
I solved by problem by not using a vector in that method, but I'd really be happy if somebody could explain what's going on here - and how this is connected to the other two blocks of code which have nothing to do with that vector...
Daniel
P.S.: All done in C++ using VS2005, SP1 and the Qt/Boost hotfix.
P.P.S.: If this was Java I'd say the garbage collector is malfunctioning, but in C++...?