c# - How to avoid memory exception when reading, creating and sending a very large xml file? -
i working on optimize our code can read, create , send xml file can large in size (2gb).
for read , create using xmlreader
class.
we xml string other service. if store xml string in string variable takes same amount of memory. point aside, please suggest best way deal xml string memory out of bound exception doesn't occur.
i can not show code on here due company policies should not matter because code working in case of large xml string giving:
memory exception
...as mentioned.
explanation :
we 2gb xml service.
we process using streaming.
since need read xml using xmlreader, pass xml in form of string create new xml same size (2gb)
byte[] msg = buffer.extractmessage(messagestart, messageend); string msg1 = encoding.utf8.getstring(msg); createnewxmlfilefromthecurrentxmlstring(msg1);
we send new xml other service.
the best way use normalized , indexed database if that's possible you. getting data using linq should solve problems. , problem source , not logic xml files shouldn't big yours.
take here: linq xml
Comments
Post a Comment