-3
我在C++中遇到了一些內存優化問題。我的代碼如下:向量函數的C++內存優化
void readSis(string sisName) {
namaFile << "Model.prism";
namaFile2 << "Properties.csl";
ifstream infile(sisName.c_str());
Data platform;
// todo: split tiap =
platform.N = atof(readInputLine(infile).c_str());
platform.Ti = atof(readInputLine(infile).c_str());
// save Ti
ostringstream temp;
temp << platform.Ti;
Ti = temp.str();
for (int i = 0; i<platform.N; i++) {
Component tmp;
tmp.componentName = readInputLine(infile);
tmp.X = atof(readInputLine(infile).c_str());
tmp.Y = atof(readInputLine(infile).c_str());
tmp.LDU = atof(readInputLine(infile).c_str());
tmp.LDD = atof(readInputLine(infile).c_str());
tmp.MDD = atof(readInputLine(infile).c_str());
if (tmp.Y == 1)
tmp.MaxState = (4 * tmp.Y) - 2;
else if (tmp.Y>1)
tmp.MaxState = (4 * tmp.Y) - 3;
tmp.HFT = tmp.Y - tmp.X;
// looping to read every tmp input
platform.vc.push_back(tmp);
// make the .prism and .csl file
makePrism(i + 1, tmp.HFT, platform.N, tmp.componentName, tmp.X, tmp.Y, tmp.MaxState, tmp.LDD, tmp.LDU, tmp.MDD);
makeCSL(tmp.HFT, i + 1, platform.Ti, platform.N, tmp.X, tmp.Y, tmp.LDD, tmp.LDU);
}
OKStream << ";" << endl;
// export .prism and .csl into file
exportPrism();
exportCSL(platform.Ti);
cout << "Model and properties have been exported!" << endl;
// calling prism function
cout << "Calling PRISM Software in C:Program Files/prism-4.3.1/bin/prism" << endl;
cout << "Executing model and properties......" << endl;
cout << "Please wait for some moments......" << endl;
callPrismBat();
// calling readtxt function
cout << "Processing PFD.txt...." << endl;
readtxt("PFD.txt");
cout << "SIL calculation has been done in file SILCalc.SIS" << endl << endl;
}
我的問題是,我想使它成爲0(零)再次調用callPrismBat()
功能之前優化我使用的內存。任何人都可以幫助我嗎?
謝謝!
請問您能詳細說明您的「某些問題」嗎? *爲什麼*你想做「內存優化」?我們無法幫助您解決一個我們並不瞭解的問題。 –
你是什麼意思:「我想優化我的已用內存」? –
什麼是「它」? – molbdnilo