System.OutOfMemoryException:Out of Memory Error using [英] System.OutOfMemoryException: Out Of Memory Error Using

查看:63
本文介绍了System.OutOfMemoryException:Out of Memory Error using的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





任何人都可以帮我紧急。



我有一个压缩和解压缩时我的数据表中的lakh记录和序列化之后我得到类型'System.OutOfMemoryException'的异常被抛出



我正在使用WCF + WPF



我的代码是



  public   static  MemoryStream DataTableSerialization(DataTable dtSearchDataTable)
{
System.IO.MemoryStreamstream = newSystem.IO.MemoryStream();

System.Runtime.Serialization.IFormatterformatter = newSystem.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
byte [] bytes = null ;

MemoryStream memory = new MemoryStream();

try
{
dtSearchDataTable.RemotingFormat = SerializationFormat.Binary;

formatter.Serialize(stream,dtSearchDataTable); // 这里我收到错误
bytes = stream.ToArray();

使用(vargzip = newGZipStream(memory,CompressionMode.Compress, true ) )
{
gzip.Write(bytes, 0 ,bytes.Length);
}

memory.Position = 0 ;

// ---为了在客户端反序列化期间启用阅读选项,我们需要设置Position = 0
}
catch (Exceptionex)
{
}
finally

{
stream.Dispose();
MinimizeMemory();
}

返回内存;
}





我的Webconfig(WCF)



< pre lang =HTML> < opentimeout receivetimeout = 04:10:00 sendtimeout = 04:01:00 >
bypassProxyOnLocal =false
hostNameComparisonMode = StrongWildcard
maxBufferSize =2147483647
maxBufferPoolSize =2147483647
maxReceivedMessageSize =2147483647
messageEncoding =Text
textEncoding =utf-8
useDefaultWebProxy =true
allowCookies =false>
< readerQuotasmaxdepth < span class =code-attribute> maxstringcontentlength = 2147483647 maxarraylength = 2147483647 >

maxBytesPerRead =4096maxNameTableCharCount =16384/>
bindingname =SearchBindingcloseTimeout =04:01:00>
< / readerquotasmaxdepth >
< / opentimeout >







- 编辑MK -

添加了代码标记。甚至没有尝试正确格式化web.config部分,但这是一个不完整的片段。请排序。

解决方案

Hi,

Can any one please help me its urgent.

I am having one lakh record in my datatable while compress and de compress and after serialize i am getting Exception of type 'System.OutOfMemoryException' was throw

I AM USING WCF+WPF

My Code is

public static MemoryStream DataTableSerialization(DataTable dtSearchDataTable)
{
    System.IO.MemoryStreamstream = newSystem.IO.MemoryStream();
 
    System.Runtime.Serialization.IFormatterformatter = newSystem.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
    byte[] bytes = null;

    MemoryStream memory = new MemoryStream();  

    try
    {
        dtSearchDataTable.RemotingFormat = SerializationFormat.Binary;
        
        formatter.Serialize(stream, dtSearchDataTable);//Here i am getting error 
        bytes = stream.ToArray();
        
        using (vargzip = newGZipStream(memory, CompressionMode.Compress, true))
        {
            gzip.Write(bytes, 0, bytes.Length);
        }
        
        memory.Position = 0; 
        
        // ---  In order to enable reading option during Deserialzation on client side we need to set Position = 0
        }
    catch(Exceptionex)
    {  
    } 
    finally
    
    {
        stream.Dispose();
        MinimizeMemory();
    }            

    return memory;
}



My Webconfig(WCF)

<opentimeout receivetimeout="04:10:00" sendtimeout="04:01:00">
bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"           
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"    
messageEncoding="Text"
textEncoding="utf-8"
useDefaultWebProxy="true"      
allowCookies="false">
<readerQuotasmaxdepth maxstringcontentlength="2147483647" maxarraylength="2147483647">
 
maxBytesPerRead="4096"maxNameTableCharCount="16384"/>
                 bindingname="SearchBinding"closeTimeout="04:01:00">
</readerquotasmaxdepth>
</opentimeout>




- Edit MK -
Added code tags. Didn't even try to correctly format the web.config part though, it's an incomplete snippet. Please sort that out.

解决方案

这篇关于System.OutOfMemoryException:Out of Memory Error using的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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