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 6064623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:18:02+00:00 2026-05-23T09:18:02+00:00

The question is a lot similar to Will malloc implementations return free-ed memory back

  • 0

The question is a lot similar to Will malloc implementations return free-ed memory back to the system?, but I am interested about an answer for Windows / Microsoft Visual Studio, and about details on the exact virtual memory state.

Will Visual C++ CRT free return the memory back to the system? What will be the exact state of the memory in respect to virtual memory allocations? After doing free on a large memory block, will the memory in the block be committed, reserved, or free? What if I call _heapmin after the free?

  • 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-23T09:18:02+00:00Added an answer on May 23, 2026 at 9:18 am

    Inspecting the source code for 2010, it can be seen malloc/free call HeapAlloc/HeapFree Win32 API functions directly, with a _crtheap as a heap created by the runtime. The answer for VS 2010 and recent Windows versions (Win2000, WinXP, Vista, Win 7) therefore is:

    The memory returned by the free is returned to OS, but it stays committed.

    Heap Functions documentation says following regarding how is the memory commitment handled:

    The HeapCreate function creates a private heap object from which the calling process can allocate memory blocks by using the HeapAlloc function. … Additional pages are automatically committed from this reserved space if requests by HeapAlloc exceed the current size of committed pages, assuming that the physical storage for it is available. Once the pages are committed, they are not decommitted until the process is terminated or until the heap is destroyed by calling the HeapDestroy function.

    Moreover, HeapCreate documentation says following regarding the case of a heap with no maximum size set:

    If dwMaximumSize is 0, the heap can grow in size. The heap’s size is limited only by the available memory. Requests to allocate memory blocks larger than the limit for a fixed-size heap do not automatically fail; instead, the system calls the VirtualAlloc function to obtain the memory that is needed for large blocks. Applications that need to allocate large memory blocks should set dwMaximumSize to 0.

    I did not find anything which would say whether those block allocated using VirtualAlloc are handled in a special way when released, an experiment would probably be needed to know this.

    As for _heapmin, with VS 2010 is does nothing, as it only calls HeapCompact and the CRT heap does not have automatic coalesce on free turned off. The documentation for _heapmin, therefore, seems wrong, most likely a relic from some old version of the runtime.

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

Sidebar

Related Questions

Similar, but different to this question : I use highlight occurrences a lot, but
There are a lot of questions similar to this but none dealing with webforms
There are a lot of similar questions, but, probably, mine is a little bit
This question seems to have been asked a lot, but I haven't seen an
Possible Duplicate: Chaining a function in JavaScript? I asked a similar question , but
I posted a question similar to this earlier, however, after thinking about it and
I read a lot of question and answer on TDD and unit testing on
I asked a similar question, but it was closed for being too broad. Basically,
there is a similar question in here but for some reason I cannot make
I have posted a question on here previously asking similar advise, but this project

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.