Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Serialization - Dealing with the Out of memory exception (Workaround)

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

[Image: xc2Aqla.png]

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. :)
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...-in-c.html
(Jan 27, 2017 12:05 PM)debug Wrote:  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...-in-c.html

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.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by LunarManureDec 10, 2020 05:21 PM 13 531 Dec 10, 2020 05:21 PM
Last Post: LunarManure
[C#] by KUi29929Aug 11, 2020 12:09 PM 1 295 Aug 11, 2020 12:09 PM
Last Post: VisualSoft
[C#] by NyxJul 22, 2020 05:58 PM 5 290 Jul 22, 2020 05:58 PM
Last Post: gigajew