I have a problem with concat two bytes []. One of them has more than 300 million bytes. This excludes the type System.OutOfMemoryException.
System.OutOfMemoryException
I am using this code:
byte[] b3 = by2.Concat(by1).ToArray();
can anyone help me
- Concat call ToArray , . . , , , .. , . , , (b1.Length + b2.Length) * 2. , LOH GC .
Concat
ToArray
(b1.Length + b2.Length) * 2
ToArray() -: , .
ToArray()
- :
var b3 = new byte[b1.Length + b2.Length]; Array.Copy(b1, b2, b1.Length); Array.Copy(b1, 0, b2, b1.Length, b2.Length);
, . , , , ToArray().
, , (, , ).
, , , , , .
, taks , ~ 550 . , .
.. , ~ 600 - . , , , 1 .
You should probably start thinking about other data structures, or try to save them as files and transfer them to edit memory : memmapping of the whole file needs the same contiguous area in the address space, so it solves nothing. This answer will be deleted.