Not too long ago i made a game which progressed pretty well, but for some reason crashed after approximately 30 minutes (sometimes 40). It seemed like one of my functions / pointers was leaking somewhere but i couldn't find any cause. As far as i could tell, i made sure to clear up any unused pointers.
What you describe is undefined behavior, which can have many causes. Most common are:
- Dereferencing of invalid pointers/references/iterators
- Array out-of-bound access
- Wrong use of delete or delete[] operators
- Linking of incompatible libraries (compiled with different compiler versions/settings)
The occurrence of such bugs may be a hint that you use badly abstracted code. Modern C++ features (smart pointers, STL containers) as well as compiler debug support (assertions, checked iterators) often mitigate such issues -- make sure you use them. For example,
using new and delete in your program is usually a bad idea.
I started considering that the leak was caused by one of the SFML functions i might have misinterpreted...I tried to troubleshoot some but in the end let it rest... [...] What i'm thinking at the moment is that the most used function while the game is running is the one drawing tiles to the RenderWindow.
SFML shouldn't cause such issues. And the number of times you call a function is no reliable bug indicator -- it is enough to call a function with UB once, and the error may manifest only half an hour later. That's why these things are terribly tedious to debug, and you'd better avoid them in the first place by writing good code. Some time ago, I assembled
a list of C++ tips that may help you in this regard.