Array size limitiation in Visual C/C++

J

James Kimble

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
 
D

David Fisher

James Kimble said:
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
 
E

Elie Nader

James Kimble said:
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
 
J

Joe Hotchkiss

James said:
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
 
P

Peter Koch Larsen

Elie Nader said:
James Kimble said:
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
 
C

Chris Theis

Joe Hotchkiss said:
James said:
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
 
A

Andrey Tarasevich

Peter said:
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<>'.
 
P

Peter Koch Larsen

Andrey Tarasevich said:
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<>'.
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,148
Messages
2,570,838
Members
47,385
Latest member
Joneswilliam01

Latest Threads

Top