3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-20 04:43:39 +00:00

free memory in nex_creator during GB init

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
Lev Nachmanson 2019-12-16 18:22:21 -10:00
parent 519bbc5af1
commit 580f229a16
3 changed files with 8 additions and 3 deletions

View file

@ -593,7 +593,7 @@ void nex_creator::process_map_pair(nex*e, const rational& coeff, nex_sum & sum,
} }
bool e_is_old = allocated_nexs.find(e) != allocated_nexs.end(); bool e_is_old = allocated_nexs.find(e) != allocated_nexs.end();
if (!e_is_old) { if (!e_is_old) {
m_allocated.push_back(e); add_to_allocated(e);
} }
if (e->is_mul()) { if (e->is_mul()) {
e->to_mul().m_coeff = coeff; e->to_mul().m_coeff = coeff;

View file

@ -155,7 +155,10 @@ public:
const std::unordered_map<lpvar, unsigned>& powers() const { return m_powers; } const std::unordered_map<lpvar, unsigned>& powers() const { return m_powers; }
std::unordered_map<lpvar, unsigned>& powers() { return m_powers; } std::unordered_map<lpvar, unsigned>& powers() { return m_powers; }
void add_to_allocated(nex* r) { m_allocated.push_back(r); } void add_to_allocated(nex* r) {
m_allocated.push_back(r);
CTRACE("grobner_stats_d", m_allocated.size() % 1000 == 0, tout << "m_allocated.size() = " << m_allocated.size() << "\n";);
}
// NSB: we can use region allocation, but still need to invoke destructor // NSB: we can use region allocation, but still need to invoke destructor
// because of 'rational' (and m_children in nex_mul unless we get rid of this) // because of 'rational' (and m_children in nex_mul unless we get rid of this)
@ -163,6 +166,7 @@ public:
for (unsigned j = sz; j < m_allocated.size(); j++) for (unsigned j = sz; j < m_allocated.size(); j++)
dealloc(m_allocated[j]); dealloc(m_allocated[j]);
m_allocated.resize(sz); m_allocated.resize(sz);
TRACE("grobner_stats_d", tout << "m_allocated.size() = " << m_allocated.size() << "\n";);
} }
void clear() { void clear() {

View file

@ -250,6 +250,7 @@ grobner_core::equation_set const& grobner_core::equations() {
void grobner_core::reset() { void grobner_core::reset() {
del_equations(0); del_equations(0);
m_nex_creator.pop(0);
SASSERT(m_equations_to_delete.empty()); SASSERT(m_equations_to_delete.empty());
m_to_superpose.reset(); m_to_superpose.reset();
m_to_simplify.reset(); m_to_simplify.reset();
@ -617,7 +618,7 @@ void grobner_core::superpose(equation * eq1, equation * eq2) {
return; return;
} }
equation* eq = alloc(equation); equation* eq = alloc(equation);
TRACE("grobner_d", tout << "eq1="; display_equation(tout, *eq1) << "eq2="; display_equation(tout, *eq2);); TRACE("grobner_d", tout << "eq1="; display_equation(tout, *eq1) << "eq2="; display_equation(tout, *eq2););
init_equation(eq, expr_superpose(eq1->expr(), eq2->expr(), ab, ac, b, c), m_dep_manager.mk_join(eq1->dep(), eq2->dep())); init_equation(eq, expr_superpose(eq1->expr(), eq2->expr(), ab, ac, b, c), m_dep_manager.mk_join(eq1->dep(), eq2->dep()));
if (m_nex_creator.gt(eq->expr(), eq1->expr()) || m_nex_creator.gt(eq->expr(), eq2->expr()) || if (m_nex_creator.gt(eq->expr(), eq1->expr()) || m_nex_creator.gt(eq->expr(), eq2->expr()) ||
equation_is_too_complex(eq)) { equation_is_too_complex(eq)) {