0

I am writing a CodeFix to fix a solution wide issue. If I let it run on even a medium sized project I run out of memory. Document is too small a chunk in many cases. What I would like is to let it run until I have used about 80% of process memory or 500 fixes and then skip the rest.

Paul Cohen
  • 241
  • 4
  • 14
  • Why would you use up 80% of the system resources? You need to split the operation in multiple smaller chunks – Sievajet Oct 10 '17 at 19:01
  • My fix is trivial but it could be applied to 10s of thousands of times. Think of a fix that changes every identifier to upper case in VB as a horrible example. A more real example to changing variable initialing to use the new C# Default or removing the VB “Optional” initializer when it’s value is the default value or changing to use $”” for strings instead of String.Format. All involve large numbers of fixes spread through 100’s of files and any file could have zero to thousands of potential fixes. The problem is the batchfixer and it is part of Roslyn. – Paul Cohen Oct 11 '17 at 21:33
  • Even so, you still need to limit your operation to a certain limit. And handle the operation in chunks. You're stuck with the garbage collector as it is. Post your code so we can find the memory pressure and/or leak issues. – Sievajet Oct 11 '17 at 21:42
  • That is my question, I have no control over the Roslyn WellKnownFixAllProviders, it calls my code in parallel once for each CodeFix in the document and it creates a new Document for each fix then merges them at the end. So for every fix a new immutable document is created. Change one character and you get a new document, 5,000 fixes in a document created 5,000 documents. – Paul Cohen Oct 12 '17 at 10:25

0 Answers0