OutofMemory error when downloading big size Dataflash log

Firstly thanks to all of Pixhawk and MissionPlanner developers for making such a wonderful open source project for UAV industry.
There is a little problem when I tried to download a big size Dataflasg log file through the USB interface by Mission Planner with the function of “Download DataFlash Log Via Mavlink”.
One of the log file is quite big, over 400MB. The Mission Planner always report "OutofMemoryException"error and quit downloading. Please see attached screen shot.
I tried different PC and different version of Mission Planner, it’s always failed.

This professional making QuadCopter with Pixhawk as flight control is provided by a friend company. The MicroSD card can not be accessed directly from enclosed body frame. And LOG_BITMASK of Pixhawk is quite high for debugging and they increased sensor output rate. At last I have to ask permission to open the body of frame and got the log.
But I was thinking that probably it’s not a good method for common customer to do that.
So I spent some time to check the code of MissionPlanner.
The function of “Download DataFlash Log Via Mavlink” will download data by Mavlink and store data into memory and check the lost of the data, after all data is downloaded then it will be written to disk. The MemoryStream class used by this should be automatically increased with the size of log content. Let’s say 400MB, at first MemoryStream will allocate 256MB for buffer, when it reaches the limitation, it will continue to apply continue 512MB data from system, if memory manager can not find a continuing big enough area for this block, an out of memory exception will through out. While it’s not the problem for the Mission Planner code, it’s with .Net framework MemoryStream mechanism or windows memory manager. Then I found an alternation for the MemoryStream from here codeproject.com/Articles/348 … moryStream “This is because the process address space is fragmented: large sections are taken up by the Operating System, others for the executable image, libraries, and all the other previous allocations. Once the memory manager has allocated a set of pages equivalent to the requested size, the process must map them into its address space - but if the address space does not contain a contiguous section of the requested size, the pages cannot be mapped, and the allocation fails with the OutOfMemoryException.”
So I updated MissionPlanner code and added this MemoryTributary class and change one function parameter from value copied to reference copied to avoid this exception. After testing, it works.

Code base is 1.3.31 build 1.1.5830.24166
Add MemoryTributary.cs into Lib directory.
In file MAVLinkInterface.cs

using LiquidEngine.Tools; //Add namespace of MemoryTributary

//Line 2912
public void GetLog(ushort no,ref MemoryTributary ms) // updates for Memory overflow exception from value copied to reference copied
{
//MemoryStream ms = new MemoryStream(); // updates for Memory overflow exception
….
//line 3022
return ; // changed from return ms

In file LogDownloadMavlinks.cs
using LiquidEngine.Tools; //Add namespace of MemoryTributary

//Line 173
MemoryTributary ms = new MemoryTributary(); //create instance for memory stream
// get df log from mav
MainV2.comPort.GetLog(no,ref ms); // transfer reference as parameter to avoid value copied
//Line 149
//bw.Write(ms.ToArray()); // updates for Memory overflow exception avoid to make a big array for output data
ms.WriteTo(bw.BaseStream);