<P>hi,</P>
<P>We enabed the p2so hash by adding option index-predicates='yes' when creating rdf storage.</P>
<P> </P>
<P>When we perform below sparqal query and the get the binding values from query results, if the query results have more than 1 bindings, there is memory leaking issue.</P>
<P> </P>
<P>e.g.</P>
<P> </P>
<P>data:</P>
<P><s1> <p1> <o1></P>
<P><s2> <p1> <o2></P>
<P> </P>
<P>query:</P>
<P>select ?s ?o where {</P>
<P>?s <p1> ?o</P>
<P>}</P>
<P> </P>
<P> </P>
<P> </P>
<P>code to get bindings from query results is similar to example5: </P>
<P> </P>
<P> while(!librdf_query_results_finished(results)) {<BR> const char **names=NULL; <BR> librdf_node* values[10];<BR> <BR> if(librdf_query_results_get_bindings(results, &names, values))<BR> break;<BR></P>
<P> // do something on the value<SPAN id=__iebugfix__></SPAN> </P>
<P><BR> librdf_query_results_next(results);<BR> }</P>
<P> </P>
<P> </P>
<P>I think the root cause of memory leak is in the function librdf_storage_hashes_node_iterator_get_method() of rdf_storage_hashes.c:</P>
<P><FONT color=#cc0000>...</FONT></P>
<P><FONT color=#cc0000> case (LIBRDF_STATEMENT_SUBJECT|LIBRDF_STATEMENT_OBJECT): /* p2so */<BR> ... </FONT></P>
<P><FONT color=#cc0000> node=librdf_new_node_from_node(context->search_node);<BR> if(!node)<BR> return NULL;<BR> librdf_statement_set_predicate(&context->statement2, node);<BR> ...</FONT></P>
<P> </P>
<P>it didn't free the original node when it set the new node as predicate of statment2, finally only the latest predicate node can be freed. Seems we <FONT color=#cc0000><FONT color=#000000>should free the original predicate node of statement2 before</FONT><BR> librdf_statement_set_predicate(&context->statement2, node);<BR><FONT color=#000000></FONT></FONT></P>
<P><FONT color=#cc0000><FONT color=#000000>After doing this, no memory leak (testing with Valgrind)</FONT></FONT></P>
<P><FONT color=#cc0000></FONT> </P>