Skip to content

Add custom 'Selected.*' type to PSCustomObject in Select-Object only once - #11548

Merged
Ilya (iSazonov) merged 2 commits into
PowerShell:masterfrom
iSazonov:fix-select-object-empty
Jan 25, 2020
Merged

Ilya (iSazonov) merged 2 commits into
PowerShell:masterfrom
iSazonov:fix-select-object-empty

Conversation

@iSazonov

@iSazonov Ilya (iSazonov) commented Jan 10, 2020 •

Copy link
Copy Markdown
Collaborator

PR Summary

Fix #11441

Before the fix Select-Object without parameters added custom 'Selected.' type to PSCustomObject even if this type was already present in TypeNames that was a memory leak in the edge case.
The cause of the problem was that Select-Object without parameters did not create a new object but forwarded the original.
The fix is to add custom 'Selected.
' type only if object is original and it has not already custom 'Selected.*' type.

PR Context

PR Checklist

@iSazonov Ilya (iSazonov) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Jan 10, 2020
@iSazonov Ilya (iSazonov) added this to the 7.1.0-preview.1 milestone Jan 10, 2020
@iSazonov Ilya (iSazonov) self-assigned this Jan 10, 2020
@iSazonov
Ilya (iSazonov) merged commit eb47c22 into PowerShell:master Jan 25, 2020
@iSazonov
Ilya (iSazonov) deleted the fix-select-object-empty branch January 25, 2020 09:10
@ghost

Copy link
Copy Markdown

🎉v7.1.0-preview.1 has been released which incorporates this pull request.:tada:

Handy links:

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
…once (PowerShell#11548)

Before the fix Select-Object without parameters added custom 'Selected.' type to PSCustomObject even if this type was already present in TypeNames that was a memory leak in the edge case.
The cause of the problem was that Select-Object without parameters did not create a new object but forwarded the original.
The fix is to add custom 'Selected.' type only if object is original and it has not already custom 'Selected.*' type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug in PS 5,6 and 7] Memory leak when Select-Object on $Global scope array of PSCustomObject

3 participants