Hey guys, here's the problem
Essentially, I have a very large list, which in turn contains relatively large dictionaries
Basically, I have a very large collection of memory.
Then I serialize this collection manually in XML and send it via http. It goes without saying that the XML is too large, sometimes so large, that I get an OutOfMemory exception before trying to send it.
In .NET, how could I calculate the potential memory usage. . For example, in this case, I have to break the XML into pieces, processing only small amounts of the collection at a time.
How to effectively calculate the size of each "piece" on the fly. I don’t want to choose an arbitrary number, for example, “process 100 elements at any time”, I want to know approximately how big each piece should be for each case.
amuses
UPDATE
Although @Jacob provided the best solution for this particular problem, the conceptual structure of the application itself is a drawback.
In fact, the solution is to execute part of your message in order to calculate how potentially a message can be when you are working with a collection.
Then you send each block with an acceptable size, one by one.
But this is only a hack. The real solution is to either find a way to not send large messages, or use a completely different protocol.
, , SOAP, .