hi,
We enabed the p2so hash by adding option index-predicates='yes' when creating 
rdf storage.
 
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.
 
e.g.
 
data:
<s1> <p1> <o1>
<s2> <p1> <o2>
 
query:
select ?s ?o where {
?s <p1> ?o
}
 
 
 
code to get bindings from query results is similar to example5: 
 
  while(!librdf_query_results_finished(results)) {
    const char **names=NULL; 
    librdf_node* values[10];
    
    if(librdf_query_results_get_bindings(results, &names, values))
      break;

    // do something on the value    

    librdf_query_results_next(results);
  }
 
 
I think the root cause of memory leak is in the function 
librdf_storage_hashes_node_iterator_get_method()  of rdf_storage_hashes.c:
...
    case (LIBRDF_STATEMENT_SUBJECT|LIBRDF_STATEMENT_OBJECT): /* p2so */
     ... 
      node=librdf_new_node_from_node(context->search_node);
      if(!node)
        return NULL;
      librdf_statement_set_predicate(&context->statement2, node);
      ...
 
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 
should free the original predicate node of statement2 before
      librdf_statement_set_predicate(&context->statement2, node);

After doing this, no memory leak (testing with Valgrind)
 
_______________________________________________
redland-dev mailing list
[email protected]
http://lists.librdf.org/mailman/listinfo/redland-dev

Reply via email to