Skip to content

Commit 4c06807

Browse files
committed
Free memory of NE if they are not used
1 parent 0e9e403 commit 4c06807

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

highs/ipm/hipo/ipm/FactorHiGHSSolver.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,17 @@ Int FactorHiGHSSolver::analyseAS(Symbolic& S) {
401401
return status ? kStatusErrorAnalyse : kStatusOk;
402402
}
403403

404+
void FactorHiGHSSolver::freeNEmemory() {
405+
// Swap NE data structures with empty vectors, to guarantee that memory is
406+
// freed.
407+
408+
std::vector<Int>().swap(ptrNE_);
409+
std::vector<Int>().swap(rowsNE_);
410+
std::vector<Int>().swap(ptrNE_rw_);
411+
std::vector<Int>().swap(idxNE_rw_);
412+
std::vector<Int>().swap(corr_NE_);
413+
}
414+
404415
Int FactorHiGHSSolver::analyseNE(Symbolic& S, int64_t nz_limit) {
405416
// Perform analyse phase of augmented system and return symbolic factorisation
406417
// in object S and the status. If building the matrix failed, the status is
@@ -507,6 +518,7 @@ Int FactorHiGHSSolver::chooseNla() {
507518
if (status != kStatusErrorAnalyse) {
508519
if (options_.nla == kOptionNlaAugmented) {
509520
S_ = std::move(symb_AS);
521+
freeNEmemory();
510522
} else {
511523
S_ = std::move(symb_NE);
512524
}

highs/ipm/hipo/ipm/FactorHiGHSSolver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class FactorHiGHSSolver : public LinearSolver {
4242
int64_t nz_limit = kHighsIInf);
4343
Int buildNEvalues(const HighsSparseMatrix& A,
4444
const std::vector<double>& scaling);
45+
void freeNEmemory();
4546

4647
Int analyseAS(Symbolic& S);
4748
Int analyseNE(Symbolic& S, int64_t nz_limit = kHighsIInf);

0 commit comments

Comments
 (0)