Skip to content

[Windows] Fix incorrect use of GetProcessMemoryInfo's return value. - #1315

Closed
mylhyz wants to merge 1 commit into
meta:mainfrom
mylhyz:main
Closed

mylhyz wants to merge 1 commit into
meta:mainfrom
mylhyz:main

Conversation

@mylhyz

@mylhyz mylhyz commented Feb 18, 2024

Copy link
Copy Markdown

Summary

According to the API documentation GetProcessMemoryInfo function (psapi.h)

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

Test Plan

  • Turn on ShouldRecordStats ( GCConfig.h )
  • Be able to get the actual value instead of 0

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Feb 18, 2024
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@tmikov has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@tmikov

tmikov commented Feb 18, 2024

Copy link
Copy Markdown
Contributor

Thank you for this! Yet another example of how harmful auto can be in C++.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@tmikov merged this pull request in 5f28c30.

facebook-github-bot pushed a commit that referenced this pull request Feb 23, 2024
)

Summary:
Original Author: mylhyz@gmail.com
Original Git: 5f28c30
Original Reviewed By: neildhar
Original Revision: D53901267

According to the API documentation [GetProcessMemoryInfo function (psapi.h)
](https://learn.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-getprocessmemoryinfo)

> If the function succeeds, the return value is nonzero.
> If the function fails, the return value is zero. To get extended error information, call [GetLastError](https://learn.microsoft.com/en-us/windows/desktop/api/errhandlingapi/nf-errhandlingapi-getlasterror).

Pull Request resolved: #1315

Pulled By: tmikov

Reviewed By: avp

Differential Revision: D54092045

fbshipit-source-id: f83eb20f0287c24e3dd9e23a93992b2700d748b2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity. Merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants