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?
138 Views Asked by Physician At
1
There are 1 best solutions below
Related Questions in C++
- C++ using std::vector across boundaries
- Linked list without struct
- Connecting Signal QML to C++ (Qt5)
- how to get the reference of struct soap inherited in C++ Proxy/Service class
- Why we can't assign value to pointer
- Conversion of objects in c++
- shared_ptr: "is not a type" error
- C++ template using pointer and non pointer arguments in a QVector
- C++ SFML 2.2 vectors
- Lifetime of temporary objects
- I want to be able to use 4 different variables in a select statement in c ++
- segmentation fault: 11, extracting data in vector
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- How can I print all the values in this linked list inside a hash table?
- Configured TTL for A record(s) backing CNAME records
Related Questions in WINDOWS
- Get Maximum Log Size
- Debugging Windows Services while starting
- Possible consequences of duplicate ProgId for different classes
- How to chain BCryptEncrypt and BCryptDecrypt calls using AES in GCM mode?
- mingw-64 conflicting declarations when cross-compiling
- I run an EXE program from a Windows Service but I can't see form C#?
- Why is PowerShell "not recognized" when installing Chocolatey?
- How to check if Windows device is phone or tablet/pc?
- How to add directories to Cygwin gcc default search path
- Can't install anything with pip2 on Windows 7 due to UnicodeDecodeError
- Active directory and linux nslcd binding without extending the AD schema
- How To Prevent Over Scrolling in Scroll Viewer Windows Phone 8.1
- Unicode error from pip install
- Where is the 'EnablePinning' property in the ribbon framework's recent items?
- How can I implement the same models and data across ASP.NET and Windows Apps
Related Questions in MULTITHREADING
- new thread blocks main thread
- WPF MessageBox Cancel checkbox check
- How to avoid concurrent access to a resource?
- run oncomplete event in async
- Threading Segfault when reading members
- Function timeouts in C and thread
- How are multiple requests to Task.Run handled from a resource management standpoint?
- Acumatica perfomance with threads
- Wait and Notify in Java threads for a given interval
- Different behavior of async with Visual Studio 2013(Windows8.1) and GCC 4.9(Ubuntu14.10)
- How to return blocking queue to the right object?
- background thread using Task.Run
- deletion and cleanup of worker thread in Qt crashes
- Pipeline-like operation using TChan
- implementing in app purchase on android
Related Questions in STACK-OVERFLOW
- Visual Studio loses first stack frames on StackOverflowException
- Silverlight Nested Custom Controls results in StackOverflowException
- System.Web.HttpcontextBase problems in Orchard 1.8 (possibly due to Visual studio 2015)
- Calling functions from each other causing stackoverflow error
- StackOverflowException while calling native (DllImport) function
- Gradle : Stackoverflow Error
- Stackoverflow error with ActionListeners
- Form reference causing Stackoverflow Exception
- Stackoverflow exception when using many enumarations inside my class
- Nop Sled, can you explain it to me?
- StackOverflow error due to recursion in Java
- BigInteger memory leak causes stack overflow in Java
- Why does attempt to access InnerText property cause Stack Overflow Expection when using HtmlAgilityPack?
- How do i dynamically allocate memory to a 2D array in C avoiding the stack overflow issue?
- Why i'm getting exception StackOverFlowException ? And how to solve it?
Related Questions in STACK-SIZE
- warning C6262: Function uses '27688' bytes of stack: exceeds /analyze:stacksize '16384'. Consider moving some data to heap
- Why is the max recursion depth I can reach non-deterministic?
- Appending the -Xss64m flag in the config.ini file doesn't work
- how to find default stack size in java
- cc1plus.exe crash when using large precompiled header file
- Can I ask a running thread about how much stack it has been using?
- How to determine Stack size of a Program in linux?
- C embedded systems stack and heap size
- When build with anycpu, it has stackoverflow exception
- Setting stack size with GCC 4.6.2 C++ Qt, MinGW, Vista
- How to set stacksize to unlimited OS X 10.8?
- Stack Overflow when using gp2c but not when using gp directly with the same program (PARI/GP)
- Error:"Uncaught RangeError: Maximum call stack size exceeded" nested in self function
- importScripts Call Stack Size Exceeded in Chrome
- If the size of my stack is exceeded, how do I automatically adjust it? C++
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 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.