![]() |
|
[.NET] Serialization - Dealing with the Out of memory exception (Workaround) - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] Serialization - Dealing with the Out of memory exception (Workaround) (/showthread.php?tid=5535448) |
Serialization - Dealing with the Out of memory exception (Workaround) - Barret - Jan 27, 2017 For those that are playing around with the serialization features i want to give a small suggestion slash workaround trick, you might hit your head on the 'Out of memory' exception whilst saving or loading up a big (200mb or bigger) serialized object. Two things to overcome this: Option 1. Change the target CPU to 64bits ![]() Option 2. GC.Collect Implement a method that would call the 'GC.Collect' after a several 'n' amount of iterations. I do strongly suggest you don't spam the 'GC.Collect', ive been reading that this operation is heavy on performance. Alright, take care. :) * - debug - Jan 27, 2017 GC.Collect should be used very sparingly, as it blocks the main thread and hinders performance. Here's a nice write up: http://www.infoworld.com/article/3099113/application-development/my-two-cents-on-gc-collect-method-in-c.html * - Barret - Jan 27, 2017 (Jan 27, 2017 12:05 PM)debug Wrote: GC.Collect should be used very sparingly, as it blocks the main thread and hinders performance. True, but lets assume you rarely use serialized xml or objects above 500mb or even above the 1gb. I don't see why you would use it in the first place. But if you must, then these are your options. |