Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,305 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,052 people online right now. Registration is fast and FREE... Join Now!




stack overflow exception

 
Reply to this topicStart new topic

stack overflow exception

prads
post 16 Feb, 2008 - 02:13 PM
Post #1


D.I.C Head

**
Joined: 22 Oct, 2007
Posts: 111


My Contributions


Hello,
When i execute my code on Visual C++ 2005, i get the following error:
An unhandled exception of type 'System.StackOverflowException' occurred and then points to this part of my code.

CODE


void xcorr(double bits[], int preamble_ms[], int bit_count, int end_of_bits)
{
    double extPreambles[37000];

    for( unsigned long int i=0; i<160; i++)
        extPreambles[i]=preamble_ms[i];
    for( unsigned long int i=160; i<37000; i++)
        extPreambles[i]=0;
// more statements
//more statements
}


Can somebody help me debug this.
Thanks,
prads
User is offlineProfile CardPM

Go to the top of the page

Nayana
post 16 Feb, 2008 - 07:06 PM
Post #2


DIC Hawk - 나야나 नयन:

Group Icon
Joined: 14 Nov, 2007
Posts: 824



Thanked 5 times

Dream Kudos: 175
My Contributions


I think the root problem is sometime before that.

Do you have a stack trace?
User is offlineProfile CardPM

Go to the top of the page

NickDMax
post 16 Feb, 2008 - 08:33 PM
Post #3


2B||!2B

Group Icon
Joined: 18 Feb, 2007
Posts: 2,857



Thanked 47 times

Dream Kudos: 550
My Contributions


generally speaking "stackoverflow" is caused by:

#1 Overuse of large local variables
#2 Overuse of or runaway recursion.

you have allocated a large array double extPreambles[37000]; in the local scope so this is eating up stackspace for each call to this function (note when the function exits the memory is free to be used again).

If this function is called recursively, or if you have allocated other large arrays in functions that call this function perhaps you should look into using some dynamic memory.
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/22/08 02:09AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month