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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:36:07+00:00 2026-05-16T08:36:07+00:00

How much memory or other resources is used for an individual VirtualAlloc (xxxx, yyy,

  • 0

How much memory or other resources is used for an individual VirtualAlloc (xxxx, yyy, MEM_RESERVE, zzz)?

Is there any difference in resource consumption (e.g. kernel paged/nonpaged pool) when I allocated one large block, like this:

VirtualAlloc( xxxx, 1024*1024, MEM_RESERVE, PAGE_READWRITE )

or multiple smaller blocks, like this:

VirtualAlloc( xxxx, 64*1024, MEM_RESERVE, PAGE_READWRITE );
VirtualAlloc( xxxx+1*64*1024, 64*1024, MEM_RESERVE, PAGE_READWRITE );
VirtualAlloc( xxxx+2*64*1024, 64*1024, MEM_RESERVE, PAGE_READWRITE );
...
VirtualAlloc( xxxx+15*64*1024, 64*1024, MEM_RESERVE, PAGE_READWRITE );

If someone does not know the answer but can suggest an experiment which would be able to check it, it will be helpful as well.

The motivation is I want to implement returning memory back to OS for TCMalloc under Windows. My idea is to replace individual large VirtualAlloc calls by performing a sequence of small (allocation granularity) calls, so that I can call VirtualFree on each of them. I am aware this way the allocation of large blocks will be slower, but are there any resource consumption penalties be expected?

  • 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-16T08:36:08+00:00Added an answer on May 16, 2026 at 8:36 am

    Just FYI, you can use GetProcessMemoryInfo and GlobalMemoryStatusEx to get some memory usage measurements.

    void DisplayMemoryUsageInformation()
    {
        HANDLE hProcess = GetCurrentProcess();
        PROCESS_MEMORY_COUNTERS pmc;
        ZeroMemory(&pmc,sizeof(pmc));
        GetProcessMemoryInfo(hProcess,&pmc, sizeof(pmc));
        std::cout << "PageFaultCount:             " << pmc.PageFaultCount             << std::endl;
        std::cout << "PeakWorkingSetSize:         " << pmc.PeakWorkingSetSize         << std::endl;
        std::cout << "WorkingSetSize:             " << pmc.WorkingSetSize             << std::endl;
        std::cout << "QuotaPeakPagedPoolUsage:    " << pmc.QuotaPeakPagedPoolUsage    << std::endl;
        std::cout << "QuotaPagedPoolUsage:        " << pmc.QuotaPagedPoolUsage        << std::endl;
        std::cout << "QuotaPeakNonPagedPoolUsage: " << pmc.QuotaPeakNonPagedPoolUsage << std::endl;
        std::cout << "QuotaNonPagedPoolUsage:     " << pmc.QuotaNonPagedPoolUsage     << std::endl;
        std::cout << "PagefileUsage:              " << pmc.PagefileUsage              << std::endl;
        std::cout << "PeakPagefileUsage:          " << pmc.PeakPagefileUsage          << std::endl;
    
        MEMORYSTATUSEX msx;
        ZeroMemory(&msx,sizeof(msx));
        msx.dwLength = sizeof(msx);
        GlobalMemoryStatusEx(&msx);
        std::cout << "MemoryLoad:                 " << msx.dwMemoryLoad               << std::endl;
        std::cout << "TotalPhys:                  " << msx.ullTotalPhys               << std::endl;
        std::cout << "AvailPhys:                  " << msx.ullAvailPhys               << std::endl;
        std::cout << "TotalPageFile:              " << msx.ullTotalPageFile           << std::endl;
        std::cout << "AvailPageFile:              " << msx.ullAvailPageFile           << std::endl;
        std::cout << "TotalVirtual:               " << msx.ullTotalVirtual            << std::endl;
        std::cout << "AvailVirtual:               " << msx.ullAvailVirtual            << std::endl;
        std::cout << "AvailExtendedVirtual:       " << msx.ullAvailExtendedVirtual    << std::endl;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In designing any desktop applications, are there any general rules on how much memory
How much memory and/or other resources does Apache web server use? How much more
How would you go about finding out how much memory is being used by
Is there a tool or a way to find out how much memory consumed
I'm using MySQL with PHP. I want to measure how much memory and other
I'm trying to find out how much memory my own .Net server process is
I am trying to find out how much memory my application is consuming from
I'm trying to find out how much memory my objects take to see how
How can I determine how much memory each device driver is consuming? I'm assuming
What is the easiest way to find out how much memory an object uses

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.