By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,159 Members | 913 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,159 IT Pros & Developers. It's quick & easy.

Array size limitiation in Visual C/C++

P: n/a
I'm porting a Unix app that I developed to windows and I'm having a
terrible time getting the bloody thing to work. I can compile just
fine but when I run I get stack overflow errors. I started taking
things apart and found that the problem stems from the size of the
arrays I'm declaring. These are arrays of structures and some of them
are quite large (100,000 elements, it's an engineering app).

I've been able to get things working by reducing the array sizes but
I'd really like to know the limits for Visual C/C++ 6.0? The largest
array I have is now down to 15,000 elements and that's going to just
barely cover what I need (but not the future need). Unix handles this
without a hitch with some of the arrays at 250,000 elements. Do I have
to download the GNU compiler or is this just a Windows limitation?

Thanks for any help you can give me,

James Kimble
Jul 22 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a

"James Kimble" <jk*****@one.net> wrote:
I'm porting a Unix app that I developed to windows .... the problem stems from the size of the
arrays I'm declaring. These are arrays of structures and some of them
are quite large (100,000 elements, it's an engineering app).


Is there a particular reason not to use dynamically allocated arrays (or
std::vector)
and allocate them when they are first needed ?

David F
Jul 22 '05 #2

P: n/a


"James Kimble" <jk*****@one.net> wrote in message
news:<ed**************************@posting.google. com>...
I'm porting a Unix app that I developed to windows and I'm having a
terrible time getting the bloody thing to work. I can compile just
fine but when I run I get stack overflow errors. I started taking
things apart and found that the problem stems from the size of the
arrays I'm declaring. These are arrays of structures and some of them
are quite large (100,000 elements, it's an engineering app).

I've been able to get things working by reducing the array sizes but
I'd really like to know the limits for Visual C/C++ 6.0? The largest
array I have is now down to 15,000 elements and that's going to just
barely cover what I need (but not the future need). Unix handles this
without a hitch with some of the arrays at 250,000 elements. Do I have
to download the GNU compiler or is this just a Windows limitation?

Thanks for any help you can give me,

James Kimble


dear James.
you can't handle big array under windows UNLESS you are using pointers.
i had this problem while handling a static array of size 100000
(Array[100000]).
this will give a successful compilation, but a big time run-time error.
SOLUTION:
use pointers;
instead of declaring a static array of 100000 like this:
int Array[100000;
do this:
int* Array = NULL ; //<<this is a pointer poiting to NULL(be sure to
include <iostream>)
Array = new int [100000] ; //<<here, you just created a Dynamic array
of 100000

after you are done with your array, be sure to delete it by using:
delete [ ] Array ;

anytime
Eliahooo
Jul 22 '05 #3

P: n/a
James Kimble wrote:
I'm porting a Unix app that I developed to windows and I'm having a
terrible time getting the bloody thing to work. I can compile just
fine but when I run I get stack overflow errors. I started taking
things apart and found that the problem stems from the size of the
arrays I'm declaring. These are arrays of structures and some of them
are quite large (100,000 elements, it's an engineering app).

I've been able to get things working by reducing the array sizes but
I'd really like to know the limits for Visual C/C++ 6.0? The largest
array I have is now down to 15,000 elements and that's going to just


From the online help:

"/STACK (Stack Allocations)
Home | Overview | How Do I | Linker Options

The Stack Allocations (/STACK:reserve[,commit]) option sets the size of the
stack in bytes.

To find this option in the development environment, click Settings on the
Project menu. Then click the Link tab, and click Output in the Category
box."

--
Regards,

Joe Hotchkiss,
http://joe.hotchkiss.com

XXXXXXXXXXXXXXXXXXXXXXXXX
X joe.hotchkiss X
X at baesystems.com X
XXXXXXXXXXXXXXXXXXXXXXXXX

Jul 22 '05 #4

P: n/a

"Elie Nader" <el*******@sympatico.ca> skrev i en meddelelse
news:Ev*********************@news20.bellglobal.com ...


"James Kimble" <jk*****@one.net> wrote in message
news:<ed**************************@posting.google. com>...
I'm porting a Unix app that I developed to windows and I'm having a
terrible time getting the bloody thing to work. I can compile just
fine but when I run I get stack overflow errors. I started taking
things apart and found that the problem stems from the size of the
arrays I'm declaring. These are arrays of structures and some of them
are quite large (100,000 elements, it's an engineering app).

I've been able to get things working by reducing the array sizes but
I'd really like to know the limits for Visual C/C++ 6.0? The largest
array I have is now down to 15,000 elements and that's going to just
barely cover what I need (but not the future need). Unix handles this
without a hitch with some of the arrays at 250,000 elements. Do I have
to download the GNU compiler or is this just a Windows limitation?

Thanks for any help you can give me,

James Kimble


dear James.
you can't handle big array under windows UNLESS you are using pointers.
i had this problem while handling a static array of size 100000
(Array[100000]).
this will give a successful compilation, but a big time run-time error.
SOLUTION:
use pointers;
instead of declaring a static array of 100000 like this:
int Array[100000;
do this:
int* Array = NULL ; //<<this is a pointer poiting to NULL(be sure to
include <iostream>)
Array = new int [100000] ; //<<here, you just created a Dynamic array
of 100000

after you are done with your array, be sure to delete it by using:
delete [ ] Array ;

anytime
Eliahooo

Your solution is errorprone and tedious. Use std::vector instead.

/Peter
Jul 22 '05 #5

P: n/a

"Joe Hotchkiss" <no****@baesystems.com> wrote in message
news:3f********@baen1673807.greenlnk.net...
James Kimble wrote:
I'm porting a Unix app that I developed to windows and I'm having a
terrible time getting the bloody thing to work. I can compile just
fine but when I run I get stack overflow errors. I started taking
things apart and found that the problem stems from the size of the
arrays I'm declaring. These are arrays of structures and some of them
are quite large (100,000 elements, it's an engineering app).

I've been able to get things working by reducing the array sizes but
I'd really like to know the limits for Visual C/C++ 6.0? The largest
array I have is now down to 15,000 elements and that's going to just
From the online help:

"/STACK (Stack Allocations)
Home | Overview | How Do I | Linker Options

The Stack Allocations (/STACK:reserve[,commit]) option sets the size of

the stack in bytes.

To find this option in the development environment, click Settings on the
Project menu. Then click the Link tab, and click Output in the Category
box."


That is going to cure the symptoms (at least for a while) but not a real
solution. Using such large static arrays you're normally heading for
trouble, as the OP already experienced. I'd strongly suggest to use the
standard library's vector class.

Regards
Chris
Jul 22 '05 #6

P: n/a
Peter Koch Larsen wrote:
you can't handle big array under windows UNLESS you are using pointers.
i had this problem while handling a static array of size 100000
(Array[100000]).
this will give a successful compilation, but a big time run-time error.
SOLUTION:
use pointers;
instead of declaring a static array of 100000 like this:
int Array[100000;
do this:
int* Array = NULL ; //<<this is a pointer poiting to NULL(be sure to
include <iostream>)
Array = new int [100000] ; //<<here, you just created a Dynamic array
of 100000

after you are done with your array, be sure to delete it by using:
delete [ ] Array ;

anytime
Eliahooo

Your solution is errorprone and tedious. Use std::vector instead.
...


No, since the code being ported is written in terms of built-in C++
arrays, this solution is significantly less "error prone and tedious"
than using 'std::vector<>'.

--
Best regards,
Andrey Tarasevich

Jul 22 '05 #7

P: n/a

"Andrey Tarasevich" <an**************@hotmail.com> skrev i en meddelelse
news:RJ********************@comcast.com...
Peter Koch Larsen wrote:

[snip]
SOLUTION:
use pointers;
instead of declaring a static array of 100000 like this:
int Array[100000;
do this:
int* Array = NULL ; //<<this is a pointer poiting to NULL(be sure to include <iostream>)
Array = new int [100000] ; //<<here, you just created a Dynamic array of 100000

after you are done with your array, be sure to delete it by using:
delete [ ] Array ;

anytime
Eliahooo

Your solution is errorprone and tedious. Use std::vector instead.
...


No, since the code being ported is written in terms of built-in C++
arrays, this solution is significantly less "error prone and tedious"
than using 'std::vector<>'.

--
Best regards,
Andrey Tarasevich

Why? Do you believe that the task of changing the signature of functions
(alternatively create wrapper functions) will take longer time and be more
errorprone than replacing array-definitions with new-delete pairs? I doubt
that will be the case.

/Peter
Jul 22 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.