本文介绍了序列化和反序列化大量数据的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的序列化和反序列化代码就是它为大数据提供了内存异常..

my serialize and deserialize code is this it is giving out of memory exception for huge data..

public static byte [] seriaize(object obj)

public static byte[] seriaize(object obj)

{

BinaryFormatter oBinFormater = new BinaryFormatter();

  MemoryStream oStream = new MemoryStream();

   oBinFormater.Serialize(oStream,obj);

   Byte [] buffer = oStream.GetBuffer();

    oStream.Dispose();

   返回缓冲区;

BinaryFormatter oBinFormater = new BinaryFormatter();
  MemoryStream oStream = new MemoryStream();
   oBinFormater.Serialize(oStream, obj);
   Byte[] buffer = oStream.GetBuffer();
    oStream.Dispose();
    return buffer;

}

public static byte [] seriaize(byte [] obj){

public static byte[] seriaize(byte [] obj){

BinaryFormatter oBinFormater = new BinaryFormatter();

            MemoryStream oStream = new MemoryStream(byteArray);

            object obj = oBinFormater.Deserialize(oStream);

            oStream.Dispose();

            return obj;

BinaryFormatter oBinFormater = new BinaryFormatter();
            MemoryStream oStream = new MemoryStream(byteArray);
            object obj = oBinFormater.Deserialize(oStream);
            oStream.Dispose();
            return obj;

}

plz help ...

plz help...

vvs

推荐答案

为什么需要字节数组?


这篇关于序列化和反序列化大量数据的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 02:43