MemoryStream的"出内存" C# [英] MemoryStream "out of memory" C#

查看:161
本文介绍了MemoryStream的"出内存" C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义的数据对象(虚拟文件)的在这里看到。我有阻力,在控制视图拖放功能(拖放一个控制视图的文件,而无需一个临时本地文件)。
这能与更小的文件,但只要该文件大于说12-15megs它说,没有足够的可用内存。好像内存流是内存不足。
我可以做些什么呢?我可以采用某种更大的byte []分成几个memoryStreams和重组那些单个文件?
任何帮助将不胜感激。


解决方案

我可以以某种方式拆分较大字节[]
分成几个momoryStreams和
重组的单个文件?






当我不得不面对类似的情况我建立我自己的流内部使用的4MB的字节数组。这种分页是指它从来没有分配一个大的字节数组,它是内存流做什么。因此,转储内存流,构建自己的基础上另外一个内部的存储机制流。


I have an implementation of a custom DataObject (Virtual File) see here. I have drag and drop functionality in a control view (drag and drop a file OUT of a control view without having a temp local file). This works fine with smaller files but as soon as the file is larger than say 12-15megs it says not enough memory available. seems like the memory stream is out of memory. what can i do about this? can i somehow split a larger byte[] into several memoryStreams and reassemble those to a single file? Any help would be highly appreciated.

解决方案

can i somehow split a larger byte[] into several momoryStreams and reassemble those to a single file?

Yes.

When I had to deal with a similar situation I built my own stream that internally used byte arrays of 4mb. This "paging" means it never has to allocate ONE LARGE BYTE ARRAY, which is what memory stream does. So, dump memory stream, build your own stream based on another internal storage mechanism.

这篇关于MemoryStream的"出内存" C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆