Free memory [skip ci]

This commit is contained in:
Andrew Kane
2024-09-19 15:32:22 -07:00
parent 4d1c6ff955
commit aaff3de409
2 changed files with 11 additions and 2 deletions

View File

@@ -226,6 +226,8 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
if (element->heaptidsLength == 0) if (element->heaptidsLength == 0)
{ {
so->w = list_delete_last(so->w); so->w = list_delete_last(so->w);
pfree(element);
pfree(hc);
continue; continue;
} }

View File

@@ -938,10 +938,14 @@ HnswSearchLayer(char *base, Datum q, List *ep, int ef, int lc, Relation index, F
/* No need to decrement wlen */ /* No need to decrement wlen */
if (wlen > ef) if (wlen > ef)
{ {
HnswCandidate *hc = HnswGetPairingHeapCandidate(w_node, pairingheap_remove_first(W)); HnswPairingHeapNode *node = pairingheap_container(HnswPairingHeapNode, w_node, pairingheap_remove_first(W));
HnswCandidate *hc = node->inner;
if (discarded != NULL) if (discarded != NULL)
*discarded = lappend(*discarded, hc); *discarded = lappend(*discarded, hc);
/* TODO */
/* pfree(node); */
} }
} }
} }
@@ -950,9 +954,12 @@ HnswSearchLayer(char *base, Datum q, List *ep, int ef, int lc, Relation index, F
/* Add each element of W to w */ /* Add each element of W to w */
while (!pairingheap_is_empty(W)) while (!pairingheap_is_empty(W))
{ {
HnswCandidate *hc = HnswGetPairingHeapCandidate(w_node, pairingheap_remove_first(W)); HnswPairingHeapNode *node = pairingheap_container(HnswPairingHeapNode, w_node, pairingheap_remove_first(W));
HnswCandidate *hc = node->inner;
w = lappend(w, hc); w = lappend(w, hc);
pfree(node);
} }
return w; return w;