J'ai un problème avec l'optimisation de la mémoire en C++. Mon code est ci-dessous:Optimisation de la mémoire C++ pour la fonction vectorielle
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;
}
Mon problème est, je veux optimiser ma mémoire utilisée avant d'appeler la fonction callPrismBat()
en en faisant 0 (zéro) à nouveau. Quelqu'un peut-il m'aider s'il-vous-plaît?
Merci!
Pouvez-vous préciser le «problème que vous avez»? * Pourquoi * voulez-vous faire "optimisation de la mémoire"? Nous ne pouvons pas vous aider à résoudre un problème dont nous ne savons rien. –
Que voulez-vous dire par: "Je veux optimiser ma mémoire utilisée"? –
Et c'est quoi "ça"? – molbdnilo