Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Array overflow in Windows (http://www.go4expert.com/forums/array-overflow-windows-t2930/)

IanLiu 9Feb2007 17:20

Array overflow in Windows
Hello there.
I am new to this forum and it seems very good.

I was programming in C with Windows and I need a 2d-array with 800x800 entries.
It doesn't seem very big, but... when I run the program, it fails.


int main() {
        int M[800][800];
        return 0;

In Linux all works well. Any tips?

Ian Liu.

DaWei 9Feb2007 19:47

Re: Array overflow in Windows
Your question does not lead to an appropriate response. Information is key. How does it fail? What messages do you get? Does the system just crash? Which Windows OS are you using? The size is not unduly large, but you may have an old underpowered (in terms of memory resources) system.

IanLiu 10Feb2007 08:54

Re: Array overflow in Windows
Oh yes... sorry, I was too "hungry" for a quick solution. Well,
my PC is a:
Pentium 4, 1.7 GHz

I use Windows XP with no SP versions installed (but I think it happened with SPed windows too).

The error message is that pop-up window that appears when a program crashes and has to be closed. You have the option to report the error, or just finish it. It is something like this image:

Sorry again for the bad post!
Think this is usefull.

Ian Liu.

DaWei 10Feb2007 10:44

Re: Array overflow in Windows
I had no problem with your program with VC++ 6.0. It generated a stack overflow, however, with VC++ 2005. I checked the stack commit and stack reserve sizes in the project properties and found that both were set to 0. I set them to 1000 and fixed the problem. In 2005 you will find this at Project/(project name) Properties/Configuration Properties/Linker/System.

IanLiu 10Feb2007 11:03

Re: Array overflow in Windows
Oh yes, I forgot to say that I am not using VC++, I am using GCC, from DevCpp.

I will try to install CygWin and see if the problem persist :)
I don't like to use proprietary applications, but I wanted the program to work on windows.

Any tips on GCC?

Well, enough questions.
Good night to you!

Ian Liu.

DaWei 10Feb2007 19:20

Re: Array overflow in Windows
Another reason you should provide all the information you can when asking a question. Let me recommend Smart Questions.

With Dev-Cpp the program does indeed crash at 800 x 800. Dev-Cpp (gcc family, perhaps I should say) doesn't seem to offer an option for controlling the amount of stack allowed. Perhaps you should try allocating on the heap, as virtual memory in decent OSes tends to make the amount available unlimited (well, limited by disk size).

You're certainly entitled to prefer non-proprietary tools, but sometimes you just get fewer amenities and capabilities. I never could convince ex-wife #2 that a high-heeled shoe wasn't really the best hammer.

IanLiu 10Feb2007 19:56

Re: Array overflow in Windows
Thank you very much DaWei.
I think I've learned much more than I expected.

I just don't agree with the hammer part ;)

Best wishes,
Ian Liu.

All times are GMT +5.5. The time now is 08:43.