Skip to content

Commit 4ad2b02

Browse files
zgn-26714dzzz2001
andauthored
Fixed memory leaks and output bugs according to #6515 and #6518. (#6585)
* fix memory leak (#6515) * fix output bug (#6518) --------- Co-authored-by: dzzz2001 <[email protected]>
1 parent 9cc2775 commit 4ad2b02

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

source/module_elecstate/elecstate_print.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void print_scf_iterinfo(const std::string& ks_solver,
146146
{
147147
buf += FmtCore::format(td_fmt[i].c_str(), values[i]);
148148
}
149-
std::cout << buf;
149+
std::cout << buf<< std::fflush;
150150
}
151151
/// @brief print and check for band energy and occupations
152152
/// @param ofs

source/module_hamilt_lcao/module_gint/gint.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,10 @@ void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D) {
261261
for (int iat = 0; iat < ucell->nat; iat++) {
262262
iat2iwt[iat] = ucell->get_iat2iwt()[iat]/2;
263263
}
264-
Parallel_Orbitals *pv = new Parallel_Orbitals();
265-
pv->set(mg, ng, nb, blacs_ctxt);
266-
pv->set_atomic_trace(iat2iwt.data(), ucell->nat, mg);
267-
this-> DM2D_tmp = new hamilt::HContainer<double>(pv, nullptr, &ijr_info);
264+
Parallel_Orbitals pv{};
265+
pv.set(mg, ng, nb, blacs_ctxt);
266+
pv.set_atomic_trace(iat2iwt.data(), ucell->nat, mg);
267+
this-> DM2D_tmp = new hamilt::HContainer<double>(&pv, nullptr, &ijr_info);
268268
this-> DM2D_tmp->set_zero();
269269
#else
270270
if (this->DM2D_tmp != nullptr) {
@@ -300,6 +300,8 @@ void Gint::transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D) {
300300
this->DMRGint[is]->add(*(this->DM2D_tmp));
301301
#endif
302302
}
303+
delete this->DM2D_tmp;
304+
this->DM2D_tmp = nullptr;
303305

304306
}
305307
ModuleBase::timer::tick("Gint", "transfer_DMR");

0 commit comments

Comments
 (0)