From b13784b3e07fc59e68937d78f526d629d10dfa92 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Feb 2026 23:08:31 +0000 Subject: [PATCH] Revert "Fix memory leak in mpz pointer tagging implementation" This reverts commit 64d5544a3228e54a22e5fe4b444c0cb1d828c875. As explained by @NikolajBjorner, the original implementation intentionally did NOT free memory on set() calls. This was a performance optimization to avoid reallocating memory when the mpz cell needs large numbers again later. The deallocate() calls introduced in the previous commit would cause performance regressions, particularly in code paths like Simplex that frequently reset values. The actual memory leak must be in the original pointer tagging commit (2f4abe2ce6b69b82fbcf86c4fa6bc9e6eaacf23b) and needs to be fixed there rather than by adding deallocate() calls in set() methods. Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> --- src/util/mpz.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/util/mpz.h b/src/util/mpz.h index 9e047929c..8f9548462 100644 --- a/src/util/mpz.h +++ b/src/util/mpz.h @@ -299,7 +299,6 @@ class mpz_manager { void set_i64(mpz & c, int64_t v) { if (v >= INT_MIN && v <= INT_MAX) { - deallocate(c); // Free any existing large value before setting small c.set(static_cast(v)); } else { @@ -590,7 +589,6 @@ public: void set(mpz & target, mpz const & source) { if (is_small(source)) { - deallocate(target); // Free any existing large value before setting small target.set(source.value()); } else { @@ -599,7 +597,6 @@ public: } void set(mpz & a, int val) { - deallocate(a); // Free any existing large value before setting small a.set(val); } @@ -618,7 +615,6 @@ public: void set(mpz & a, uint64_t val) { if (val < INT_MAX) { - deallocate(a); // Free any existing large value before setting small a.set(static_cast(val)); } else {