CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Main CFD Forum (http://www.cfd-online.com/Forums/main/)
-   -   Why I can not allocate five 256*256 array in VC++ (http://www.cfd-online.com/Forums/main/1879-why-i-can-not-allocate-five-256-256-array-vc.html)

Aspens February 29, 2000 10:25

Why I can not allocate five 256*256 array in VC++
 
Hi.

When I making a small CFD program, I need 5 256*256 array in calculation (single precision). However, the program run into error when execute. (for samller array everything goes OK). Is there some configuration of cmoplier I should set when I use VC++ to make large scale calculation?

Thanks,

Aspens,

Chris February 29, 2000 15:27

Re: Why I can not allocate five 256*256 array in VC++
 
5 256*256 float arrays is less than 2MB. There should be no problem allocating that amount, so you have probably made a mistake in the code. Is the allocation failing (check the return from malloc or new), or are you getting an error later?

Aspens February 29, 2000 23:11

Re: Why I can not allocate five 256*256 array in VC++
 
Hi. It complies and builds Ok, but when I run it, it says "unexpected ..". When I tried to step into the program, it gives me a Stack Overflow signal, and I can not even start it! I am working in VC++, is there any switch to set this stack size? Their help simply does not help.

sincerely,

Apsens,

Tareq Al-shaalan February 29, 2000 23:51

Re: Why I can not allocate five 256*256 array in VC++
 
Check your subroutines. may be you are steping to a momery place where the divition by zero happens.

Steve March 1, 2000 04:06

Re: Why I can not allocate five 256*256 array in VC++
 
It depends what you mean by allocate.

If you have five local arrays inside a function, they will normally be allocated on the stack each time the function is called. This will crash your program if the stack is too small. You can get around this by declaring them static inside the function, which will cause their storage to be allocated differently (on the heap), preventing the stack from overflowing.

If you are dynamically allocating 256*256 floats and 256 float pointers to simulate each 256x256 2D array, check each malloc return value against NULL (for failure).


All times are GMT -4. The time now is 05:32.