Gourav Kumar <gourav1...@gmail.com> writes: > I have modified the PostgreSQL source code for my project implementation. > In the modified code, I am calling query_planner function several times > while I am inside the grouping planner function.
> As the number of executions increase I have noticed memory leaks in the > code. I have pinpointed it to be inside the query_planner, using the > heaptrack tool. But, I am unable to figure out the exact location of it. The planner eats memory like there's no tomorrow. This is intentional; it'd be nearly impossible to release very much given the intertwining of its data structures. You might be able to do something similar to what GEQO does, and run speculative planning calls inside a short-lived memory context that you can reset after each run. The trick there would be to draw a line between what the speculative calls modify and don't modify. I'm afraid GEQO's line isn't very close to what you need, if you're hoping to repeat all of query_planner(). Also you're going to have lots of problems with query_planner changing the input Query tree. Personally I'd suggest not going in that direction, but instead think in terms of having query_planner return more Paths. regards, tom lane