So let's say I have created a thread, on Windows OS, for which I know that the default stack size is much more than what is needed. Can I then run the application and ask the thread about the amount of stack it actually has used so that I know how much I should set its stack size instead of the default stack size?
Can I ask a running thread about how much stack it has been using?
140 Views Asked by Physician At
1
There are 1 best solutions below
Related Questions in C++
- How to immediately apply DISPLAYCONFIG_SCALING display scaling mode with SetDisplayConfig and DISPLAYCONFIG_PATH_TARGET_INFO
- Why can't I use templates members in its specialization?
- How to fix "Access violation executing location" when using GLFW and GLAD
- Dynamic array of structures in C++/ cannot fill a dynamic array of doubles in structure from dynamic array of structures
- How do I apply the interface concept with the base-class in design?
- File refuses to compile std::erase() even if using -std=g++23
- How can I do a successful map when the number of elements to be mapped is not consistent in Thrust C++
- Can std::bit_cast be applied to an empty object?
- Unexpected inter-thread happens-before relationships from relaxed memory ordering
- How i can move element of dynamic vector in argument of function push_back for dynamic vector
- Brick Breaker Ball Bounce
- Thread-safe lock-free min where both operands can change c++
- Watchdog Timer Reset on ESP32 using Webservers
- How to solve compiler error: no matching function for call to 'dmhFS::dmhFS()' in my case?
- Conda CMAKE CXX Compiler error while compiling Pytorch
Related Questions in WINDOWS
- how to play a sounds in c# forms?
- Echo behaviour of Microsoft Windows Telnet Client
- Getting error while running spark-shell on my system; pyspark is running fine
- DirectX 9 With No SDK Installed - How To Translate a D3DMATRIX?
- Gradle 8.7 cannot find installed JDK 22 in IntelliJ
- 'IOException: The cloud file provider is not running', when trying to delete 'cloud' folder
- Cannot load modules/mod_dav_svn.so into server
- Issue with launching application after updating ElectronJs to version 28.0.0 on Windows and Linux
- 32-bit applications do not display some files in Windows 10
- 'bun' is not recognized as an internal or external command
- mkssecreenshotmgr taking a screenshot
- Next js installation in windows 7 os
- Can't resize a partition using Mini Tool?
- Is there any way to set a printer as default according with Active Directory Policy Security Group and PC hostname?
- Electron Printing not working on Windows (Works on Mac)
Related Questions in MULTITHREADING
- How can I outsource worker processes within a for loop?
- OpenMP & oneTbb difference
- Receiving Notifications for Individual Task Completion OmniThreadLibrary Parallel.ForEach
- C++ error: no matching member function for call to 'enqueue' futures.emplace_back(TP.enqueue(sum_plus_one, x, &M));
- How can I create a thread in Haskell that will restart if it gets killed due to any reason?
- Qt: running callback in the main thread from the worker thread
- Using `static` on a AVX2 counter function increases performance ~10x in MT environment without any change in Compiler optimizations
- Heap sort with multithreading
- windows multithreading CreateMutex
- The problem of "fine-grained locks and two-phase locking algorithm"
- OpenMP multi-threading not working if OpenMPI set to use one or two MPI processor
- WPF Windows Initializing is locking the separated thread in .Net 8
- TCP Client Losing Connection When Writing Data
- vc++ thread constructor throwing compiler error c2672
- ASP.NET Core 6 Web API : best way to pause before resending email
Related Questions in STACK-OVERFLOW
- How to allocate a large structure in a heap baked `Arc<T>` without stack overflow in Rust?
- Build failed: Your build exceed the maximum build time of 120 minutes
- intelliJ Error when build the Project - Cause: java.lang.StackOverflowError
- Ran on an MCU (STM32F1), doubly-linked list code results in a call of HardFault() due to stack overflow
- How to turn off login pop-up on stackoverflow
- stack overflow error occurs only when converting to a type with the Error method defined
- Does an Stackoverflow occur in the JVM if the Activation Record is too small but there is still space left in the general stack?
- Automapper with Record types causing StackOverflowException
- Stack overflow when finding all paths through a grid with recursion and backtracking
- What refactoring should I apply on this email validation regex?
- Can someone explain why this is throwing a stackoverflow error? (Scala, lazylist, nth prime number)
- How to fix Recursion Function overflow error?
- Why is a topic locked as off-topic
- How to detect a Stack Overflow error in C++Builder 2010?
- How can I implement screen tapping functionality programmatically in Flutter to simulate user clicks?
Related Questions in STACK-SIZE
- how to find default stack size in java
- С++ checking thread stack size with crashing
- RangeError: Maximum call stack size exceeded NEXTJS
- GNU ld linker: stack-size=value has no effect
- RangeError: Maximum call stack size exceeded in a context.js file when using a custom hook in React
- Increase Python Stack Size
- Uncaught RangeError: Maximum call stack size exceeded can't figure out why
- Can I ask a running thread about how much stack it has been using?
- Where is Max Stack Size set on ORACLE database machines running ORACLE LINUX 7 (on top of VMWARE)
- Winston logger causing "Maximum call stack size exceeded" error
- How to change stack size limit in NodeJS?
- How do i define the task size in xTaskCreate()?
- Different ways of setting recursion limit/stack size in Python
- maximum call stack size exceeded in local database data fetch in for loop
- Stack Overflow when using gp2c but not when using gp directly with the same program (PARI/GP)
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Windows usually doesn't commit the entire stack, it only reserves it. (Well, unless you ask it to, e.g. by specifying a non-zero stack size argument for
CreateThreadwithout also passing theSTACK_SIZE_PARAM_IS_A_RESERVATIONflag).You can use this to figure out how much stack your thread has ever needed while running, including any CRT, WinAPI or third-party library calls.
To do that, simply read the
StackBaseandStackLimitvalues from the TEB - see answers to this question for how to do that. The difference of the two values should be the amount of stack memory that has been committed, i.e. - the amount of stack memory that the thread has actually used.Alternatively, if a manual process is sufficient: Simply start the application in WinDBG, set a breakpoint before the thread exits and then dump the TEB with the
!tebcommand. You can also dump the entire memory map with!addressand look for committed areas with usageStack.