From: Michael Gerdau <mgd@te...>  20050727 09:28:52

> Any help or comments concerning the following problem will be greatly > appreciated. Basically, I am developing a scientific application which u= ses > Fortran 90, C, and C++ code, and does some heavy operations on matrices. = The > details are unimportant (I think), as the program runs to completion with= out > issues using 3D matrices of smallish sizes. When the matrix dimensions a= re > increased to say, 128 x 128 x 128, it appears as if I am running out of > memory...malloc() is failing and responding with errno 12 which maps to n= ot > enough memory. The problem is that according to every way I have been > monitoring the memory of my system, I have plenty left! If anyone can co= me up > with any explanation, or even just something to investigate, I would very= much > appreciate it...I am running on Windows XP with MinGW and Msys, using G95= to > compile and link, and using g++/gcc to compile the c++/c code. Thanks so= much > for everyones time. Could you provide a small testprogram that shows this problem ? The following code works without problems on WinXP when compiled with mingwgcc3.4.4. #include <stdlib.h> #include <stdio.h> #define MATRIX_COUNT 30 #define MATRIX_DIM_1 128 #define MATRIX_DIM_2 128 #define MATRIX_DIM_3 128 int main(int argc, char** argv) { double**** aMatrix =3D (double****)malloc(MATRIX_COUNT*sizeof(double***= )); if (!aMatrix) { printf("*** Could not malloc %d double***\n", MATRIX_COUNT); exit(1); } for (int i=3D0; i<MATRIX_COUNT; ++i) { aMatrix[i] =3D (double***)malloc(MATRIX_DIM_1*sizeof(double**)); if (!aMatrix[i]) { printf("*** i=3D%d: Could not malloc %d double**\n", i, MATRIX_DIM_1); exit(1); } for (int j=3D0; j<MATRIX_DIM_1; ++j) { aMatrix[i][j] =3D (double**)malloc(MATRIX_DIM_2*sizeof(double*)); if (!aMatrix[i][j]) { printf("*** i=3D%d, j=3D%d: Could not malloc %d double*\n", i, j, MATRIX_= DIM_2); exit(1); } for (int k=3D0; k<MATRIX_DIM_2; ++k) { aMatrix[i][j][k] =3D (double*)malloc(MATRIX_DIM_3*sizeof(double)); if (!aMatrix[i][j][k]) { printf("*** i=3D%d, j=3D%d, k=3D%d: Could not malloc %d double\n", i,= j, k, MATRIX_DIM_3); exit(1); } } } } printf("Successfully allocated %d matrixes of %d x %d x %d double\n", M= ATRIX_COUNT, MATRIX_DIM_1, MATRIX_DIM_2, MATRIX_DIM_3); exit(0); } Best, Michael =2D=20 Vote against SPAM  see http://www.politikdigital.de/spam/ Michael Gerdau email: mgd@... GPGkeys available on request or at public keyserver 