J'ai un code qui doit être "traduit" de C à Cpp, et je ne comprends pas, où est un problème. Il y a la partie, où il se bloque (fenêtres erreur critique Envoyer/dontSend):Problème d'allocation de mémoire C/Cpp Windows erreur critique
nDim = sizeMax*(sizeMax+1)/2;
printf("nDim = %d sizeMax = %d\n",nDim,sizeMax);
hamilt = (double*)malloc(nDim*sizeof(double));
printf("End hamilt alloc. %d allocated\n",(nDim*sizeof(double)));
transProb = (double*)malloc(sizeMax*sizeMax*sizeof(double));
printf("End transProb alloc. %d allocated\n",(sizeMax*sizeMax*sizeof(double)));
eValues = (double*)malloc(sizeMax*sizeof(double));
printf("eValues allocated. %d allocated\n",(sizeMax*sizeof(double)));
eVectors = (double**)malloc(sizeMax*sizeof(double*));
printf("eVectors allocated. %d allocated\n",(sizeMax*sizeof(double*)));
if(eVectors) for(i=0;i<sizeMax;i++) {
eVectors[i] = (double*)malloc(sizeMax*sizeof(double));
printf("eVectors %d-th element allocated. %d allocated\n",i,(sizeMax*sizeof(double)));
}
eValuesPrev = (double*)malloc(sizeMax*sizeof(double));
printf("eValuesPrev allocated. %d allocated\n",(sizeMax*sizeof(double)));
eVectorsPrev = (double**)malloc(sizeMax*sizeof(double*));
printf("eVectorsPrev allocated. %d allocated\n",(sizeMax*sizeof(double*)));
if(eVectorsPrev) for(i=0;i<sizeMax;i++) {
eVectorsPrev[i] = (double*)malloc(sizeMax*sizeof(double));
printf("eVectorsPrev %d-th element allocated. %d allocated\n",i,(sizeMax*sizeof(double)));
}
Log:
nDim = 2485 sizeMax = 70
End hamilt alloc. 19880 allocated
End transProb alloc. 39200 allocated
eValues allocated. 560 allocated
eVectors allocated. 280 allocated
Il se bloque au début de la boucle d'allocation. Si je supprime cette boucle, elle se bloque à la prochaine ligne d'allocation. Est-ce que ça veut dire qu'avec les chiffres comme ça je n'ai pas assez de mémoire?
Merci.
argh .. un meilleur formatage s'il vous plaît! – Macke