8-puzzle problem, with memory leaks. C++
I'm trying to apply breadth first search algorithm to solve 8-puzzle game in C++, the algorithm works fine, and so far finds the necessary moves to solve a 3x3 problem. But using fsanitize, I got a lot of memory leaks, I checked the code for hours and not sure why the code still have memory leaks, here's the code (somehow solo learn doesn't show any output). https://code.sololearn.com/cA2a0887A14A Basically, each Node has the possible state after you move the blank tile up, down, left, right, my_deque holds all the possible states and possible_paths holds the nodes with the possible states depending of its current state. The function expand_node() - line 73 - Is reserving some memory to those nodes and inserting it to a deque. That's why when I reach my goal, at lines 106-109 I'm deleting those nodes that were reserved in expand_node() function. I'm also deleting the memory that was reserved from expand_node(), deleting each node that it's already visited (123-126). Finally, I return current_state that is a node, each node has a parent so, I delete each parent after printing what moves you need to solve the puzzle, (166-169). But still... fsanitize throws me some memory leaks... I'm not sure if I'm deleting correctly or where I need to delete more. Any idea about how can I solve this?