maapi_query_free_result() only frees the reply ETERM stored in qr->__internal when the result chunk is non-empty. When a query chunk
comes back with zero results, the reply term is never freed, leaking the
whole 5-element tuple plus its children and the erl_malloc’ed element
block (about 500 bytes per call).
In my point of view, this should be:
if (qr->nresults > 0) {
...
free(qr->results[0].str); /* the block */
free(qr->results); /* the result array */
}
/* Free the reply term even when the query returned no results,
otherwise every empty maapi_query_result() chunk leaks it. */
if (qr->__internal) {
ETERM *e = qr->__internal;
erl_free_compound(e);
}
free(qr);
Any thoughts on this? Is there a ConfD version where this issue is already fixed?