当底层文件大小更多时,使用memoryStream导致OutOfMemory异常。 [英] Using memoryStream causing OutOfMemory exception when the underlying file size is more.

查看:320
本文介绍了当底层文件大小更多时,使用memoryStream导致OutOfMemory异常。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当底层文件大小更多时,使用memoryStream导致OutOfMemory异常。 FileStream不会抛出任何异常。



1。为什么它适用于FileStream?



2。除了使用FileStream之外,是否还有其他解决方案来修复此异常。

解决方案

基础文件大小更多......什么?


您尝试阅读的文件有多大? FileStream只根据需要从文件中流入数据,但是内存流将所有数据保存在内存中(根据定义),并且它可以容纳多少数据。


所以你可能会收到一个OutOfMemory错误,因为你实际上是内存不足!


如果你不相信这种情况,你可以发布你的代码来证明这个问题吗?


Using memoryStream causing OutOfMemory exception when the underlying file size is more. FileStream does not throw any exception.

1. Why its working for FileStream?

2. Apart from using FileStream, is there any other solution to fix this exception.

解决方案

underlying file size is more...what?

How big is the file you are trying to read in? A FileStream only streams the data in from the file as needed but a memory stream holds all it's data in memory (by definition) and there is a limit to how much data it can hold.

So you may be getting an OutOfMemory error because you are actually out of memory!

If you don't believe this to be the case, could you post up your code to demonstrate the issue?


这篇关于当底层文件大小更多时,使用memoryStream导致OutOfMemory异常。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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