utils: Use GetProcessWorkingSetSizeEx to get limit for Win32LockedPageAllocator #17494

pull fanquake wants to merge 1 commits into bitcoin:master from fanquake:windows_page_allocator_getlimit changing 1 files +5 −2
  1. fanquake commented at 4:02 PM on November 16, 2019: member

    This returns 1413120 in the virtual machine I've been using for testing.

    More info: https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-getprocessworkingsetsizeex.

  2. utils: Use GetProcessWorkingSetSizeEx to get limit for WinLockedPageAllocator
    This returns 1413120 in the VM I've used for testing.
    
    More info: https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-getprocessworkingsetsizeex
    322496dee4
  3. fanquake added the label Windows on Nov 16, 2019
  4. fanquake added the label Utils/log/libs on Nov 16, 2019
  5. in src/support/lockedpool.cpp:206 in 322496dee4
     199 | @@ -200,8 +200,11 @@ void Win32LockedPageAllocator::FreeLocked(void* addr, size_t len)
     200 |  
     201 |  size_t Win32LockedPageAllocator::GetLimit()
     202 |  {
     203 | -    // TODO is there a limit on Windows, how to get it?
     204 | -    return std::numeric_limits<size_t>::max();
     205 | +    size_t minSet;
     206 | +    size_t maxSet;
     207 | +    DWORD flags;
     208 | +    GetProcessWorkingSetSizeEx(GetCurrentProcess(), &minSet, &maxSet, &flags);
    


    laanwj commented at 2:13 PM on November 18, 2019:

    This needs error handling. I think logging a warning and returning 0 is good enough, but right now this will potentially return an invalid or uninitialized value in the case of an error.


    sipsorcery commented at 3:59 PM on March 11, 2020:
  6. laanwj commented at 2:14 PM on November 18, 2019: member

    Concept ACK

  7. fanquake added the label Waiting for author on Nov 19, 2019
  8. laanwj commented at 3:17 PM on March 11, 2020: member

    Would be good to get some more review here from windows-minded devs maybe @luke-jr @sipsorcery

  9. sipsorcery commented at 4:16 PM on March 11, 2020: member

    I don't think this will compile on x86 Windows.

    The PSIZE_T output parameters use SIZE_T which has a different definition for x86 and x64. SIZE_T is equivalent to std::size_t for x64 but not x86. The fix is to use SIZE_T instead but that introduces an additional Windows specific type.

  10. fanquake added the label Up for grabs on Apr 22, 2020
  11. fanquake removed the label Waiting for author on Apr 22, 2020
  12. fanquake closed this on Apr 22, 2020

  13. DrahtBot locked this on Feb 15, 2022
  14. fanquake deleted the branch on Aug 4, 2022
  15. fanquake commented at 2:08 PM on August 4, 2022: member

    Removing up for grabs as this was done in #25320.

  16. fanquake removed the label Up for grabs on Aug 4, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me