C# Increase Heap Size - Is It Possible

后端 未结 5 963
离开以前
离开以前 2020-12-07 01:01

I have an out of memory exception using C# when reading in a massive file

I need to change the code but for the time being can I increase the heap size (like I would

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-07 01:53

    What sort of file are you dealing with ?

    You might be better off using a StreamReader and yield returning the ReadLine result, if it's textual.

    Sure, you'll be keeping a file-pointer around, but the worst case scenario is massively reduced.

    There are similar methods for Binary files, if you're uploading a file to SQL for example, you can read a byte[] and use the Sql Pointer mechanics to write the buffer to the end of a blob.

提交回复
热议问题