Jump to content
  • Advertisement
Sign in to follow this  
MTclip

stack overflow question?

This topic is 4849 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So i have encountered a new problem today... STACK OVERFLOW.. i googled it.. basically I found out that it means I have used up all the local function calling memory wich is aboout 1mb... i checked for infinte type loops.. wich as i knew there are none.. how can i deal with this... is there away to increase the stack? thanks for anything....

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
What does the callstack look like when it goes boom?

Share this post


Link to post
Share on other sites
Increasing the size of your stack depends on what linker you use. If you have MSVC the linker option is /STACK.

Also, you can a stack overflow if you allocate large arrays on the stack.

Share this post


Link to post
Share on other sites
when you ask what the call stack looks like... do you mean the ..locals..

I am using MSVC... is it ok to increase the stack ... or is that not good practice....

EDIT:: okay well i found the CALLSTACK and it is certainly overloaded... with the same function so somehow there is an infinte loop.. im gonna check in to this.. thanks

Share this post


Link to post
Share on other sites
In general, the default stack size of 1 megabyte is enough for an application. I'd try to find out why you are getting a stack overflow (infinite recursion, too big of an array allocated as a local variable, etc.)

Share this post


Link to post
Share on other sites
No, you should not increase the stack size. 1MB is already a waste of memory for a stack size.

You may have done something like this:



#define BIG_NUMBER 1024

void SomeFunc(void)
{
double SomeBigArray[BIG_NUMBER*256]; // oops, variable on stack is 8*1024*256 = 2MB

//some code

}


Share this post


Link to post
Share on other sites
To add to what SiCrane wrote, expanding the stack size won't necessarily resolve the problem. It will just take a little longer for the stack to break.

Share this post


Link to post
Share on other sites
yeah .. well this is what i did


CTexture * CPart:: getTexture()
{
this->getTexture();
}
/// INFINTE LOOOOOOOOOOP!!!!

/// was supposed to be this
CTexture * CPart:: getTexture()
{
this->m_pTexture;
}


haha .. well at least i learned some stuff...( stack stuff ;P )
problem solved...
thanks..

Share this post


Link to post
Share on other sites
You should have caught that problem in like 5 seconds with the debugger. If you don't know how to use the debugger, learn. It is an invaluable tool.

Share this post


Link to post
Share on other sites
This is not an infinite loop, it's called infinite recursion, since you have a function that calls itself until it uses up all the stack memory :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!