-
Notifications
You must be signed in to change notification settings - Fork 27
Description
I believe there is a space leak in the else branch here:
mpl/runtime/gc/hierarchical-heap.c
Lines 1337 to 1341 in a71659b
| if (retireInsteadOfFree) { | |
| HH_EBR_retire(s, child); | |
| } else { | |
| freeFixedSize(myUFAllocator, child); | |
| } |
The space leak is never materializing because at the moment this branch is unused. HM_HH_freeAllDependants is called in exactly two places, both with retireInsteadOfFree=TRUE.
(We're essentially seeing an artifact of a previous memory management strategy.)
Some background:
Every union-find node has an HH struct as a payload, and the HH struct also needs to be freed. For example, when EBR eventually frees a union-find node, the corresponding payload is also freed:
mpl/runtime/gc/hierarchical-heap-ebr.c
Lines 14 to 19 in a71659b
| void freeUnionFind (GC_state s, void *ptr) { | |
| HM_UnionFindNode hufp = (HM_UnionFindNode)ptr; | |
| assert(hufp->payload != NULL); | |
| freeFixedSize(getHHAllocator(s), hufp->payload); | |
| freeFixedSize(getUFAllocator(s), hufp); | |
| } |
Presumably, the fix should be as simple as adding the line freeFixedSize(getHHAllocator(s), child->payload) to the else branch highlighted at the top of the issue... but it's not easy to test, because of the unused branch. Perhaps a better fix would be to put a mandatory crash with DIE(...) in the else branch to mark it for future inspection.