Skip to content

Commit 673d008

Browse files
committed
fix memory leak
1 parent cecbcdd commit 673d008

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

source/module_cell/atom_spec.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ void Atom::bcast_atom(void)
142142
{
143143
assert(na!=0);
144144
delete[] tau;
145+
delete[] tau_original;
145146
delete[] taud;
146147
delete[] vel;
147148
delete[] mag;

source/module_cell/read_atoms.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ bool UnitCell_pseudo::read_atom_positions(std::ifstream &ifpos, std::ofstream &o
567567
if (na > 0)
568568
{
569569
delete[] atoms[it].tau;
570+
delete[] atoms[it].tau_original;
570571
delete[] atoms[it].taud;
571572
delete[] atoms[it].vel;
572573
delete[] atoms[it].mbl;

source/module_esolver/esolver_sdft_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ void ESolver_SDFT_PW::postprocess()
144144
{
145145
GlobalC::en.print_occ();
146146

147-
((hsolver::HSolverPW_SDFT*)phsol)->stoiter.cleanchiallorder();//release lots of memories
148147
if(this->maxniter == 0)
149148
{
150149
int iter = 1;
@@ -153,6 +152,7 @@ void ESolver_SDFT_PW::postprocess()
153152
hsolver::DiagoIterAssist::PW_DIAG_THR = std::max(std::min(1e-5, 0.1 * GlobalV::SCF_THR / std::max(1.0, GlobalC::CHR.nelec)),1e-12);
154153
hsolver::DiagoIterAssist::need_subspace = false;
155154
this->phsol->solve(this->phami, this->psi[0], this->pelec,this->stowf,istep, iter, GlobalV::KS_SOLVER, true);
155+
((hsolver::HSolverPW_SDFT*)phsol)->stoiter.cleanchiallorder();//release lots of memories
156156
}
157157
int nche_test = 0;
158158
if(INPUT.cal_cond) nche_test = std::max(nche_test, INPUT.cond_nche);

source/src_pw/sto_iter.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
double vTMv(const double *v, const double * M, const int n)
1313
{
14-
char normal = 'N';
15-
double one = 1;
16-
int inc = 1;
17-
double zero = 0;
14+
const char normal = 'N';
15+
const double one = 1;
16+
const int inc = 1;
17+
const double zero = 0;
1818
double *y = new double [n];
1919
dgemv_(&normal,&n,&n,&one,M,&n,v,&inc,&zero,y,&inc);
2020
double result = BlasConnector::dot(n,y,1,v,1);
@@ -200,11 +200,12 @@ void Stochastic_Iter::check_precision(const double ref, const double thr, const
200200
#ifdef __MPI
201201
MPI_Allreduce(MPI_IN_PLACE, &error, 1, MPI_DOUBLE, MPI_SUM , MPI_COMM_WORLD);
202202
#endif
203-
GlobalV::ofs_running<<info<<" Chebyshev Precision: "<<abs(error/ref)*1e9<<"E-09"<<std::endl;
204-
if(error/ref > thr)
203+
double relative_error = abs(error/ref);
204+
GlobalV::ofs_running<<info<<" Chebyshev Precision: "<<relative_error*1e9<<"E-09"<<std::endl;
205+
if(relative_error > thr)
205206
{
206207
stringstream ss;
207-
ss<<abs(error/ref);
208+
ss<<relative_error;
208209
string fractxt,tartxt;
209210
ss>>fractxt;
210211
ss.clear();

0 commit comments

Comments
 (0)