Skip to content

Possible Memory Leak in Foreach -Parallel, version 7.rc1 #11478

@OtterKring

Description

@OtterKring

Steps to reproduce

$messageids | ForEach-Object -Parallel {$mid = $_; $using:log | 
    ? messageid -eq $mid | 
    Sort-Object ExactTimeStamp | 
    Select-Object -first 1} | 
    Export-Csv mtl_midunique.csv -Encoding utf8 -NoTypeInformation

$log held ~70000 lines imported from a csv holding the export of get-messagetrackinglog, $messageids had ~60000 lines imported from a csv, holding unique messageids
"ExactTimeStamp" was build from the TimeStamp property, format 'yyyyMMddHHmmssfff'

Expected behavior

quicker iteration through the date than single threaded, steady memory usage

Actual behavior

memory usage of the process building up to several GBs, slowing down the iteration to much less than this single threaded code:

 &{foreach ($mid in $messageids) {&{foreach ($entry in $log) {if ($entry.messageid -eq $mid) {$entry}}} | 
    Sort-Object ExactTimeStamp | 
    Select-Object -first 1}} | 
    Export-Csv mtl_midunique.csv -Encoding utf8 -NoTypeInformation

Environment data

Name Value


PSVersion 7.0.0-rc.1
PSEdition Core
GitCommitId 7.0.0-rc.1
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Metadata

Metadata

Assignees

Labels

Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-AnsweredThe question is answered.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions