I came across an opinion that we should avoid dynamic memory in game as much as possible and what do you say?
Firstly I thought it doesn't really matter but now I have noticed an issue in my game.
I have variable in header file: bool **collision;
At certain stage in my game in source file I allocate memory to the variable like that:
collision = new bool *[size];//the size isn't constant, it differs at other stages
for(int i = 0; i < size; i++)
collision = new bool[size];
As the stage ends I remove the memory like that:
for(int i = 0; i < size; i++)
{
delete [] Collision::Obj().collision;
}
delete [] Collision::Obj().collision;
and repeating those actions some times causes the game crash eventually and I dont know if I have any memory leak or that is just becouse of dynamic memory in game?
I would be grateful for help!