百思不得其解的"Failed to allocate a managed memory buffer of 268435456 bytes."错误解决
2008-08-12 15:50
621 查看
最近要做一个上传功能的WCF,20M 70M都测试成后,但是在测试130M的时候,却跳出
"Failed to allocate a managed memory buffer of 268435456 bytes."
错误,
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="VODServiceBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" messageEncoding="Mtom">
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="VOD.VODServiceBehavior"
name="VOD.VODService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="VODServiceBinding" contract="VOD.IVODService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="VOD.VODServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" ignoreExtensionDataObject="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IVODService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:30:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Mtom" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://xxxxxx.com/VODService.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IVODService" contract="VODService.IVODService"
name="BasicHttpBinding_IVODService" />
</client>
</system.serviceModel>
然后从MSDN的论坛里找到了一种方法,就是分段把文件内容传到服务器上,追加到文件结尾
byte[] buffer = new byte[65000];
int bytesRead = 0;
VODService.IVODService proxy = client.ChannelFactory.CreateChannel();
while ((bytesRead = fuUpload.PostedFile.InputStream.Read(buffer, 0, 65000)) > 0)
client.ChannelFactory.Close();
我想可能是一次传的文件放在内存里太大了
希望对大家有帮助
"Failed to allocate a managed memory buffer of 268435456 bytes."
错误,
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="VODServiceBinding" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" messageEncoding="Mtom">
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="VOD.VODServiceBehavior"
name="VOD.VODService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="VODServiceBinding" contract="VOD.IVODService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="VOD.VODServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" ignoreExtensionDataObject="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IVODService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:30:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Mtom" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://xxxxxx.com/VODService.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IVODService" contract="VODService.IVODService"
name="BasicHttpBinding_IVODService" />
</client>
</system.serviceModel>
然后从MSDN的论坛里找到了一种方法,就是分段把文件内容传到服务器上,追加到文件结尾
byte[] buffer = new byte[65000];
int bytesRead = 0;
VODService.IVODService proxy = client.ChannelFactory.CreateChannel();
while ((bytesRead = fuUpload.PostedFile.InputStream.Read(buffer, 0, 65000)) > 0)
client.ChannelFactory.Close();
我想可能是一次传的文件放在内存里太大了
希望对大家有帮助
相关文章推荐
- Gerrit 执行 git pull 的时候,提示 fatal: Out of memory, malloc failed (tried to allocate *** bytes)错误的解决方法
- ORA-04031:unable to allocate 4120 bytes of shared memory ‘obj stat mem’故障解决
- Android 启动模拟器是出现“Failed to allocate memory: 8”错误提示的原因及解决办法
- OpenCV Error: Insufficient memory (Failed to allocate 47752340 bytes) in cv::OutOfMemoryError, file
- Android 启动模拟器是出现“Failed to allocate memory: 8”错误提示的原因及解决办法
- Caused by: java.lang.OutOfMemoryError: Failed to allocate a 29433932 byte allocation with 14683576 free bytes and 14MB
- Android 启动模拟器是出现“Failed to allocate memory: 8”错误提示的原因及解决办法
- Android 启动模拟器是出现“Failed to allocate memory: 8”错误提示的原因及解决办法
- Android开发笔记(2)启动模拟器出现错误"Failed to allocate memory: 8"的解决方法
- Android模拟器报"Failed To Allocate memory 8"错误的解决办法
- Android模拟器"Failed To Allocate memory 8"错误如何解决
- Android 启动模拟器是出现“Failed to allocate memory: 8”错误提示的原因及解决办法
- 解决Android 启动模拟器是出现“Failed to allocate memory: 8”错误提示
- discuz Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 262144 bytes) 错误解决方法
- Android模拟器报"Failed To Allocate memory 8"错误的解决办法
- Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 2611816 bytes)错误的解决
- Android 启动模拟器是出现“Failed to allocate memory: 8”错误提示的原因及解决办法
- Android 启动模拟器是出现“Failed to allocate memory: 8”错误提示的原因及解决办法
- Android 启动模拟器是出现“Failed to allocate memory: 8”错误提示的原因及解决办法
- opencv Insufficient memory (Failed to allocate 1520000 bytes)解决办法