It's really hard time for me to remove/avoid leaks while implementing an using XpathQuery in my project. Currently I am using libXml2.2.dylib for parsing. When I am checking for the memory leaks using instruments I found lot of leaks in the framework.
What would be the solution to avoid these leaks. Memory is more concern for us. How can I fix/avoid these buggy leaks?
First, if memory is a major concern, using XML is not your best solution anyway. JSON or a binary format are much more memory efficient.
Second, your trace does not show leaks in the framework. What is shows are leaked objects which whose memory was allocated by the framework. It is more likely that the actual leak is in your code, typically by allocating an object from the library, but then not releasing (or freeing in this case) the object. Look at the stack traces.