Created
February 11, 2016 17:38
-
-
Save svick/68dce366629baf1d4ee7 to your computer and use it in GitHub Desktop.
PLINQ leak?
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
| Processing 0 | |
| Processing 1 | |
| Finalizing #0 | |
| Processing 2 | |
| Processing 3 | |
| Finalizing #2 | |
| Processing 4 | |
| Finalizing #3 | |
| Processing 5 | |
| Finalizing #4 | |
| Processing 6 | |
| Finalizing #5 | |
| Processing 7 | |
| Finalizing #6 | |
| Processing 8 | |
| Finalizing #7 | |
| Processing 9 | |
| Finalizing #8 | |
| Finalizing #1 | |
| Finalizing #9 |
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
| void Main() | |
| { | |
| var query = Enumerable.Range(0,10) | |
| .AsParallel() | |
| .AsOrdered() | |
| .WithDegreeOfParallelism(4) | |
| .SelectMany(i => GenerateDataBatch(i)); | |
| foreach (var x in query) | |
| { | |
| $"Processing {x.I}".Dump(); | |
| GC.Collect(); | |
| GC.WaitForPendingFinalizers(); | |
| } | |
| } | |
| C[] GenerateDataBatch(int i) | |
| { | |
| return new[] { new C { I = i } }; | |
| } | |
| class C | |
| { | |
| public int I; | |
| ~C() | |
| { | |
| $"Finalizing #{I}".Dump(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment