473,786 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

stack overflow just because of a double array[500][500]?

Hi,

I am using Visual C++ 6.0. I got a "stack overflow" error message when
running the program because of a "double array[500][500]". I have a
computer with 1GB memory. Can I extend the memory for the program
running? How?

Looking forward to hearing from you!

Regards,

James
Jul 22 '05 #1
2 4293

"James" <me******@mail1 .monash.edu.au> wrote in message
news:dc******** *************** ***@posting.goo gle.com...
Hi,

I am using Visual C++ 6.0. I got a "stack overflow" error message when
running the program because of a "double array[500][500]". I have a
computer with 1GB memory. Can I extend the memory for the program
running? How?


Possibly but how big the stack is something that your compiler specifies not
the C++ language. Ask in a compiler specific group for an ansewr to this
question.

But really you should use dynamic allocation, any of the methods I suggested
in response to your last post would be prefereable to trying to declare such
a huge array on the stack.

For instance

#include <vector>

std::vector<std ::vector<double > > array(500);
for (int i = 0; i < 500; ++i)
array[i].resize(500);

is a simple way to give you a 500 by 500 2D array without blowing your
stack.

john
Jul 22 '05 #2
James wrote:
Hi,

I am using Visual C++ 6.0. I got a "stack overflow" error message when
running the program because of a "double array[500][500]". I have a
computer with 1GB memory. Can I extend the memory for the program
running? How?


It's not the "memory for the program running" it's the stack size
that is too small. <OT> You may adjust it via some compiler options,
I believe. </OT>.

Better than that, don't have this 4MB array allocated on stack
(which happens, for instance, if it's a local variable inside a
function) -- try going for dynamical allocation, using 'new' for
example. See your book's index for "new", "dynamical allocation",
and also the C++ FAQ-lite for how to handle two-dimensional
arrays using 'new'.

You might also consider using a
std::vector< std::vector <double> >
for storing your doubles.

HTH,
- J.
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
10546
by: Moshe | last post by:
Scenario - IIS 5.0 WIN2K latest SP Application ASP. An ASP Page has a text area. When submitted calls SQL server 2K Stored Procedure to update a record. The field in the data base is of type Text. When posting from the browser a text that is less then about 100K, no errors. When posting more the 100K HTTP 500 - Internal server error Tracing the database - the call to SP was not yet executed.
11
5589
by: Randell D. | last post by:
Folks I have a multi-dimensional array in javascript, as follows: gameRecord=new Array(500); gameRecord="FA Cup : 19 February 2005"; gameRecord="Arsenal v Sheff Utd, 12:30"; gameRecord="Bolton v Fulham, 15:00"; gameRecord="Charlton v Leicester, 15:00"; gameRecord="Everton v Man Utd, 17:30";
25
2726
by: Ashutosh Iddya | last post by:
Hi , I am performing an integer count of a particular operation in my program. After a sufficiently large value an overflow occurs. At the moment I have gone around the problem by declaring it as a double, even that has its limits. Is there a method of preventing this overflow or some method of recovering from it. Any help in this regard would be greatly appreciated. Thanking you.
4
6213
by: jf li | last post by:
I have a Asp.net web application and a Asp.net Web service application. The Web application is using HtmlInputFile to get a 50M size of file selected by end user, read the data of this file and pass the data to the web service. I already modified both web.config files and changed maxRequestLength to 60000(kb). When I debug the upload process, it seems the Web application can get the 50M file and read the data without problem, but when the...
9
4166
by: Eric Webster | last post by:
I have a fairly simple VB.Net program I'm developing that listens to data coming over the internet and processes it. The data comes in as events - the app is idle until another chunk of data comes through. When it does, the app looks to see what kind of data it is, and does something with it, such as parse the data, write it to a file, ignore it, etc. The code almost completes when it throws a stack overflow exception. The code makes no...
29
3311
by: foker | last post by:
I have this problem where I have 2 text files, one with student name, id#, # of courses and course #, the second file has course name and course number. I want to make a multidimensional array that takes the student id into one portion and the course id into the other. This is my code: include <iostream> #include <string> #include <fstream> using namespace std;
7
22052
by: amit.atray | last post by:
Environement : Sun OS + gnu tools + sun studio (dbx etc) having some Old C-Code (ansi + KR Style) and code inspection shows some big size variable (auto) allocated (on stack) say for ex. char a; (this type of code and other complex mallc/free etc is used frequently and total approx 450 files, each file is of approx/avg 1000 line,
13
2087
by: jm.suresh | last post by:
Hi, I have a program which literately finds the object that overlapping a point. The horizontal and vertical search are called recursively from inside each other. Is this way of implementation fill the stack space with the local variables inside each call. If this is not good, is there a better way to implement? Or python itself will understand that the calls happen in the last line, so local variables need not be pushed into the stack?
4
1680
by: lightaiyee | last post by:
Dear Gurus, I would like to implement a function that computes the number of times a certain condition is met in a global array. For example, I have an global array of size 500. float array; I have a function that finds the maximum of an array of size 50. bool findMax50(float input)
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6748
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.