473,783 Members | 2,363 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

stack limitations

Hey, is there a limit to the stack size? I realize of course there must be,
but how is this determined/set? Or does it self adjust up to, say, available
memory (and possibly virtual memory from hard drives)? My current project
can be set to be from very-stack-intensive to not-so-stack-intensive. The
more stack-intensive it is the faster the code will run, but it can
conceivable want to put huge amounts of info on the stack (there are
potentiqlly recursive processes involved).

Can I determine such things as max stack size (read/write), total stack
already used (read), etc.?

[==P==]
Nov 21 '05 #1
2 1882
>Hey, is there a limit to the stack size? I realize of course there must be,
but how is this determined/set?


Have a look at "Thread Stack Size" in MSDN.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Nov 23 '05 #2
Hey, is there a limit to the stack size? I realize of course there must be,
but how is this determined/set?
The default size is set in the executable's header (IMAGE_OPTIONAL _HEADER.SizeOfS tackReserve,
IMAGE_OPTIONAL_ HEADER.SizeOfSt ackCommit). It can be changed
using /stack linker option, or by the second parameter of CreateThread function.
Or does it self adjust up to, say, available memory (and possibly virtual memory from hard drives)?
Reserved size cannot grow, committed size can grow up to the reserved size (when the reserved size
is reached, stack overflow exception is thrown).
Can I determine such things as max stack size (read/write),
You should look at the size of the virtual memory region reserved for the stack, using any tool
that can display virtual memory map (e.g. WinDbg's !address and !vadump commands).
Programmaticall y you can check it using VirtualQuery function.

Here you can find some related information:
http://support.microsoft.com/default...b;en-us;315937
http://msdn.microsoft.com/library/de...setstkoflw.asp
total stack already used (read), etc.?


In debugger, you can use this in Watch window (when debugging in Native mode):

Currently committed size:
((unsigned long*)@TIB)[1] - ((unsigned long*)@TIB)[2]

Currently used size:
((unsigned long*)@TIB)[1] - ESP

Regards,
Oleg
[VC++ MVP]


Nov 23 '05 #3

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

Similar topics

3
12413
by: Hajir Firooz | last post by:
Hi, I am wondering what are the limitations of MS Access 2000 database in terms of number of records per table. Any help will be appreciated.
15
7742
by: Andrew | last post by:
Last night I was reading about implementing my own stack. The example given pushes items on and off the stack at the start and end of each procedure (ie. in a std module). What's not so clear is how this would work with class objects. In this case do you have to push the object on the stack at the start of every public procedure etc. in the class and pop it off at the end? I can't see how else you can know which object is active - or...
2
16374
by: Mark | last post by:
Could someone please give me a hand? I have created a navigation bar for a Web site I assist with. Everything works fine if I use the files while offline, i.e., the files that I created are sitting on my hard disk. But when I use the same files uploaded to the site, I get 'stack overflow at line: 28' (or line 0 if I change the advanced setting in IE options) whenever I mouseout of the navigation bar. The site is:...
10
8348
by: Shuo Xiang | last post by:
Greetings: I know that variables declared on a stack definitely does not reside in heap space so there is only a very limited amount of stuff that you can store in the stack of a function. But what about the global space? Is that the same as the heap space or is that still a form of special stack? Because once I've seen someone declare a 1 megabyte char array in global space like this: char s;
8
2098
by: LedZep | last post by:
What up everyone, I have to write a program that uses a stack to determine whether a string is a palindrome (a string that is spelled identically backward and forward). The program has to ignore spaces, case sensitivity and punctuation. I need three text boxes. The first will be for input of the string. The second will display the string when the "check" button is clicked and the result of the analysis (string is a palindrome or is...
1
4223
by: alfie27 | last post by:
I currently have a working program that is a stack that stores integers. Now i have to convert it to store strings instead of integers. I have been working on this for hours and just keep getting errors of all kinds. I have decided to start from scratch. Any suggestions someone can give me would be greatly appreciated!! Here is the current code: #include <iostream> using std::cout; using std::cin; #include <cstring> using std::strcpy;
7
7233
by: DevNull | last post by:
Hello everyone, I decided to pick c++ back up after not really having used it much in 10 years. Just as a point of refference, there was no standard C++ last time I used regularly. Anyways coming back, I've fallen in love with all the improvements in the language such as the STL. Congrats to anyone who worked on it, you did an excellent job.
4
2205
by: Adam | last post by:
Is there a way in C++ to allocate a variable amount of stack space at run-time? void complex_maths_operation(const int num_rows, double* vector) { double temp; .... } The obvious answer is to use the heap... but if this isn't an option.
9
369
by: beginers of c | last post by:
Which is the effective way to write stack program in C.Pointers ,structure,functions etc............... Which will be more effective
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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
10313
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
10081
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
9946
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
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
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();...
1
4044
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

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.