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

  • Home
  • SEARCH
  • 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 8364945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:32:57+00:00 2026-06-09T12:32:57+00:00

Is it possible for stack space allocated by CreateThread to interfere with the usage

  • 0

Is it possible for stack space allocated by CreateThread to interfere with the usage of VirtualAlloc? I can’t find any discussion or documentation explaining precisely where stack space is allowed to be allocated…

The following more precisely illustrates my question:

uint8_t *baseA = (uint8_t*)VirtualAlloc(NULL,1,MEM_RESERVE,PAGE_NOACCESS);

// Create a thread with the default stack size
HANDLE hThread = CreateThread(NULL,0,SomeThreadProc,NULL,NULL,NULL);

// Possibly create even more threads here.

// Can this ever fail in the absence of other allocators? It doesn't here...
uint8_t *baseB = (uint8_t*)VirtualAlloc(NULL,1,MEM_RESERVE,PAGE_NOACCESS);

// Furthermore, in this test, baseB-baseA == 65536 (unless the debugger did something),
// so nothing appeared between baseA and baseB... not even enough space for the
// full 64kb of wastage, as baseA points to 4096 bytes by itself

If it does in fact use some analogue of VirtualAlloc, is there a way to change how Windows allocates stack space in a given process?

  • 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-06-09T12:32:58+00:00Added an answer on June 9, 2026 at 12:32 pm

    Stack space can be allocated anywhere in the address space of the process. There is no documentation on this now and it is unlikely that such documentation will appear in the future.

    You can safely assume that creation of the thread and virtual alloc are independent. If this would not be the case, a lot of things would be broken. Allocator cannot give out overlapping address ranges. This is unthinkable. The problem is somewhere else.

    The only thing that might look like correlation – amount of memory used and virtual address space fragmentation. In this case the latest request will simply fail.

    I worked on a memory analysis utilities.

    enter image description here

    This picture shows distribution of the numbers of virtual allocations per size of the allocation.

    enter image description here

    This is example of the address space contents for a 32-bit process (blue – committed, magenta – reserved, green is a free memory).

    What I write here is based on a real experience.

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

Sidebar

Related Questions

Is there any way that I can Stack the jQuery UI Tabs Header? Please
It's is possible to stack fragments on top of each other? Just tried to
Is it possible to set the stack limit in DevC++? Basically the same as
Is it possible yet to compile a full PHP stack - say Apache, PHP,
Is it possible to view the complete list of call stack for a given
Possible Duplicate: What does ^ in objective C mean? [SKSite requestSiteWithNameLike:@Stack Overflow completionHandler:^(SKSite *site,
When using reflection it is possible to obtain the call stack (apart from that
Given the output of inspect.stack() , is it possible to get the function objects
i'm wondering if it is possible to programattically recurse up a stack trace to
I have the following stack trace. Is it possible to make out anything useful

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.