Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1096235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:15:12+00:00 2026-05-17T00:15:12+00:00

When writing in C, how can I tell how much stack space is available

  • 0

When writing in C, how can I tell how much stack space is available in memory when I launch a program? How about heap space?

How can I tell how much memory is being used during the execution of my program?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:15:13+00:00Added an answer on May 17, 2026 at 12:15 am

    This is all Win32-specific (not really C-specific, all just OS API):

    When a thread is created, it gets 1MB stack space by default, by that can be modified in whatever CreateThread API you use.

    You can peek into the thread information block to find the actual stack info, but even though this is documented, this technique isn’t officially supported, see http://en.wikipedia.org/wiki/Win32_Thread_Information_Block .

    Also, for a 32-bit application, you can only address up to 2GB, so for an app that by design uses lots of memory, then the thing to watch out for is the total size of the process’ virtual address space (committed + reserved), which includes all heap allocations. You can programmatically access the process’ virtual memory with the GlobalMemoryStatusEx API, look at the ullTotalVirtual param for virtual address space. Once your process gets close to 1.8 or 1.9GB of VAS, then heap allocations and VirtualAlloc calls begin to fail. For “normal” apps, you don’t have to worry about running out of VAS, but it’s always good to check for fail allocs. Also, you shouldn’t get a stack overflow, unless you have a bug, or a bad design.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I go about with writing a shell extension to display online files
How can I start writing a plugin for Eclipse ? I've looked for documentation,
How can I rewrite or is there a way to writing my own custom
When writing a custom channel how can I get the name of the service
I'm writing a page that can use a couple of different themes, and I'm
I'm writing an application that can be started either as a standard WinForms app
I am writing a JSR-168 portlet that can be added to a container multiple
I'm writing a quick Rails app and was wondering how I can validate the
I am currently writing a little bootstrap code for a service that can be
I'm writing an app where 3rd party vendors can write plugin DLLs and drop

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.