Hi Miles,
In my program, the vector<MPS>
structure is used several times in some functions. I expect the memory to be automatically freed when exiting the functions, but it is not. I have tried the "swap" trick which indeed destructs the vectors, but the total memory taken by the process still keeps growing. Making the vectors global and reusing them also does not work.
Except for sum(vector <MPS>)
:
auto terms = vector<MPS>(N);
for (int q = 0; q < N; q++){
terms.at(q) = psi;
SqActOnOpenMPS(momentum + q, terms.at(q), Operator, sites, N, Cargs);
SqActOnOpenMPS(q, terms.at(q), Operator, sites, N, Cargs);
}
Basis.at(0) = sum(terms, Cargs);
all the other operations are on only one or two MPS in the vector. Another strange thing is that the memory usage grows when calculating the overlap of two MPS in the same vector:
Nij[i][j] = overlap(Basis.at(i), Basis.at(j));
Hij[i][j] = overlap(Basis.at(i), H, Basis.at(j));
It takes ~ 20kB for each pair when the size of the (spinless) system is 20 and bond dimension ~ 200.
Is there any suggestion? Thank you.
Yilun