Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.msdos.programmer > #1433
| From | "Rod Pemberton" <dont_use_email@xnothavet.cqm> |
|---|---|
| Newsgroups | comp.os.msdos.programmer |
| Subject | Re: Stack overflow: how to monitor stack usage? |
| Date | 2014-07-25 01:42 -0400 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <op.xjjgszc66zenlw@localhost> (permalink) |
| References | <53d15c6d$0$2178$426a34cc@news.free.fr> |
On Thu, 24 Jul 2014 15:20:13 -0400, Mateusz Viste <mateusz.viste@localhost> wrote: > Hello, > > Just wondering - is there any mechanism that allows to monitor the > current usage of the stack? There is no official way to do this since C officially does not require a stack. On a POSIX system, you should be able to use alloca() to monitor changes to stack allocation. I doubt that Turbo C has it since it's for DOS, but it might. So, you should check. You could have a function that declares an a procedure local variable (auto) and returns or displays it's address. This acts like the address that would be returned by alloca() with a small value, like 2 or 4. So, your variable will be allocated at the top of the stack space. So, the variable's address represents an address that's a bit larger than what is currently in use for the stack. You'd call the function each time you want an update. The problem is this only gives an address near the top of the current stack. To determine the amount of stack in use, you need to subtract an initial address from the current address. You'll need to call your function just after entering main() and save an early value for the low value to subtract. Rod Pemberton
Back to comp.os.msdos.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Stack overflow: how to monitor stack usage? Mateusz Viste <mateusz.viste@localhost> - 2014-07-24 21:20 +0200
Re: Stack overflow: how to monitor stack usage? Johann Klammer <klammerj@NOSPAM.a1.net> - 2014-07-24 22:08 +0200
Re: Stack overflow: how to monitor stack usage? Mateusz Viste <mateusz.viste@localhost> - 2014-07-25 08:20 +0200
Re: Stack overflow: how to monitor stack usage? "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-07-25 04:34 -0400
Re: Stack overflow: how to monitor stack usage? Mateusz Viste <mateusz.viste@localhost> - 2014-07-25 12:53 +0200
Re: Stack overflow: how to monitor stack usage? Johann Klammer <klammerj@NOSPAM.a1.net> - 2014-07-25 12:07 +0200
Re: Stack overflow: how to monitor stack usage? Mateusz Viste <mateusz.viste@localhost> - 2014-07-25 12:48 +0200
Re: Stack overflow: how to monitor stack usage? Johann Klammer <klammerj@NOSPAM.a1.net> - 2014-07-25 13:18 +0200
Re: Stack overflow: how to monitor stack usage? Mateusz Viste <mateusz.viste@localhost> - 2014-07-25 14:06 +0200
Re: Stack overflow: how to monitor stack usage? Johann Klammer <klammerj@NOSPAM.a1.net> - 2014-07-25 14:48 +0200
Re: Stack overflow: how to monitor stack usage? Mateusz Viste <mateusz.viste@localhost> - 2014-07-25 15:03 +0200
Re: Stack overflow: how to monitor stack usage? Johann Klammer <klammerj@NOSPAM.a1.net> - 2014-07-25 14:59 +0200
Re: Stack overflow: how to monitor stack usage? Mateusz Viste <mateusz.viste@localhost> - 2014-07-25 15:08 +0200
Re: Stack overflow: how to monitor stack usage? Sjouke Burry <burrynulnulfour@ppllaanneett.nnll> - 2014-07-25 00:24 +0200
Re: Stack overflow: how to monitor stack usage? Mateusz Viste <mateusz.viste@localhost> - 2014-07-25 08:32 +0200
Re: Stack overflow: how to monitor stack usage? "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-07-25 01:42 -0400
Re: Stack overflow: how to monitor stack usage? Mateusz Viste <mateusz.viste@localhost> - 2014-07-25 08:45 +0200
Re: Stack overflow: how to monitor stack usage? Mateusz Viste <mateusz.viste@localhost> - 2014-07-25 21:26 +0200
Re: Stack overflow: how to monitor stack usage? "Rod Pemberton" <dont_use_email@xnothavet.cqm> - 2014-07-25 16:28 -0400
csiph-web