Default stack size

Source: Internet
Author: User

Today I read several articles about stack and stackArticleThe default size of the stack may be 1 MB or 2 MB. Try it with curiosity.

 
IntMain (IntArgc,Char* Argv[]){IntTMP[1000*256*2+1000* 3]={0};

}
 
It's about M. If it's bigger, it will appear.
 
5 [main] Test 3204 handle_exceptions: exception: status_stack_overflow 28408 [main] Test 3204 open_stackdumpfile: dumping stack trace to test.exe. stackdump
 
The environment is slickedit + GCC.
 
You can also do this:
IntMain (IntArgc,Char* Argv[]){IntI;IntJ;Printf("I address % P/R/N", & I );Printf("J address % P/R/N", & J );


}

 
 result: 
 I address 0x23eef4j address 0x23eef0 

I and j are local variables allocated in the stack. The allocation starts from the top of the stack. So the address of I is the top of the stack.

23eef4 to 0 indicates the size of the entire stack, it's about 2.3m. we can also see that

stack allocation is from high address (stack top) to the lower address, so The J address is smaller than the I address.

   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.