Unused destructured local not cleared, causes memory leak

Description

Clojure currently doesn't clear unused locals. This is problematic as some form of destructuring can generate unused/unusable locals that the compiler cannot clear and thus can cause head retention:

Here's a macroexpansion that exposes this issue:

Cause: The first two bindings of a and b will hold onto the head of c since they are never used and not accessible from the loop body they cannot be cleared.

Approach: Track whether local bindings are used. After evaluating the binding expression, if the local binding is not used and can be cleared, then pop the result rather than storing it.

Patch: 0001-CLJ-1744-clear-unused-locals-v2.patch

Screened by: Alex Miller

Environment

None

Status

Assignee

Unassigned

Reporter

Nicola Mometto

Approval

Ok

Patch

Code

Fix versions

Priority

Critical
Configure