Is there a way to tell Windows to give a program more memory? I'd rather do that than re-code a straightforward program that otherwise works well.
We have a C# program that runs every 15 minutes and compares a new incoming file to the previous file. Both the new and old file are "|" separated and read into memory. We haven't tried optimizing, just read everything into dictionaries and do a straightforward comparison.
We're getting this error,
Message: Exception of type 'System.OutOfMemoryException' was thrown. at
System.String.SplitInternal(Char[] separator, Int32 count,
StringSplitOptions options)
at System.String.Split(Char[] separator)
Each of these files have about a 1000 lines and each line has a base64 encoded large image as one of the pipe-separated fields. Each line can be 500K-700K so the total size of each file is around 600MB. Maybe an occasional line exceeds 1MB.
We estimate the program uses 1.5GB of RAM or so. I'd like to just give it more RAM instead of trying to optimize the code. Alternatively it would be nice to know if the program as a whole is running out of memory or one particular huge line may cause SplitInternal to throw this exception.
Windows Server 2012R2.
Edits: The offending line of code is just "string[] data = info.Split('|');" inside of a loop. After this exception is caught, the program continues and processes many other lines just fine.
Not averse to rewriting it, but if there's an easier way I'd like to try that first. We confirmed it was compiled with the "Prefer 32 bit" checkbox, so first we will try unchecking that and see what happens. After all, 2GB isn't really a whole lot these days on a server...