Reduce memory consumption of system_category().message()#457
Merged
BillyONeal merged 21 commits intomicrosoft:masterfrom Feb 7, 2020
sylveon:system_category_message_allocation
Merged
Reduce memory consumption of system_category().message()#457BillyONeal merged 21 commits intomicrosoft:masterfrom sylveon:system_category_message_allocation
BillyONeal merged 21 commits intomicrosoft:masterfrom
sylveon:system_category_message_allocation
Conversation
This avoids the allocation in _Winerror_message, and introduces a new version of it which uses FORMAT_MESSAGE_ALLOCATE_BUFFER to completely avoid overallocating memory Fixes #434
BillyONeal
suggested changes
Jan 25, 2020
Member
BillyONeal
left a comment
There was a problem hiding this comment.
Thanks for your contribution!
…urface of msvcp140.dll.
…le in the build twice :(
BillyONeal
approved these changes
Feb 1, 2020
Member
BillyONeal
left a comment
There was a problem hiding this comment.
@sylveon I've extracted the new functions into the import lib so that we can avoid breaking the ABI of msvcp140.dll. Please look this over after my changes and make sure you're happy with them.
Thanks for your contribution!
Member
|
Thank you, you did the hard part. I just mostly copy/pasta'd code around to make the old build system in devdiv happy :) |
Contributor
Author
|
LGTM |
CaseyCarter
suggested changes
Feb 3, 2020
Co-Authored-By: Casey Carter <cartec69@gmail.com>
sylveon
commented
Feb 3, 2020
LocalFree already ignores arguments that are nullptr, and _System_error_message does not relies on the return value when deciding whether to free, meaning we can return 0 if the message is entirely whitespaces since the caller will clean up the message unconditionally
StephanTLavavej
requested changes
Feb 4, 2020
This was referenced Feb 4, 2020
* Make __msvc headers use consistent header guards. * Add tests for __std_get_string_size_without_trailing_whitespace. * Add nodiscard and explicit to things * Remove SAL * free => deallocate * Remove blank lines in places * Terse get_string_size loop * constexprize string length * Workaround DevCom-906503 * Remove no longer used <cstdlib> Also: * Fix link error in test * constexprize error tables
CaseyCarter
approved these changes
Feb 5, 2020
…sage_allocation # Conflicts: # stl/src/syserror.cpp
BillyONeal
approved these changes
Feb 6, 2020
StephanTLavavej
requested changes
Feb 7, 2020
StephanTLavavej
approved these changes
Feb 7, 2020
Member
|
@sylveon Thanks again for your contribution! |
fengjixuchui
added a commit
to fengjixuchui/STL
that referenced
this pull request
Feb 7, 2020
Reduce memory consumption of system_category().message() (microsoft#457)
Contributor
Author
|
You're welcome! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This avoids the allocation in
_Winerror_message, and introduces a new version of it which usesFORMAT_MESSAGE_ALLOCATE_BUFFERto completely avoid overallocating memoryFixes #434
Checklist
Be sure you've read README.md and understand the scope of this repo.
If you're unsure about a box, leave it unchecked. A maintainer will help you.
_Uglyas perhttps://eel.is/c++draft/lex.name#3.1 or there are no product code changes.
verified by an STL maintainer before automated testing is enabled on GitHub,
leave this unchecked for initial submission).
members, adding virtual functions, changing whether a type is an aggregate
or trivially copyable, etc.).
the C++ Working Draft (including any cited standards), other WG21 papers
(excluding reference implementations outside of proposed standard wording),
and LWG issues as reference material. If they were derived from a project
that's already listed in NOTICE.txt, that's fine, but please mention it.
If they were derived from any other project (including Boost and libc++,
which are not yet listed in NOTICE.txt), you must mention it here,
so we can determine whether the license is compatible and what else needs
to be done.