OutOfMemoryException in Regex Matches when processing large files

后端 未结 3 1537
野的像风
野的像风 2020-12-18 12:30

I\'ve got an exception log from one of production code releases.

System.OutOfMemoryException: Exception of type \'System.OutOfMemoryException\' was thrown.
          


        
3条回答
  •  余生分开走
    2020-12-18 13:08

    The first thing I would try, if it is possible for your application, would be to split up the input.

    Would it be possible to read the file (if the input is a file) line-by-line, applying the Regular Expression that way?

    You should take a look with CLR Profiler. It can take a little time to learn how to use, but it's worth it. It will help you visualize how much memory your objects use.

提交回复
热议问题