byte[] memory consumption excedded
-
Hi ., I have webservices method which takes parameter byte[] this byte[] parameter is compressed Dataset at client-side , Now I am Decompressing this at the server side . All this Compressing and decompressing is done to shrink the size of dataset , but now the Server pop's the error memory consumption excedded. Now, do I have any other way to compress Dataset and sent over Webservices? I did googled this problem but was enable to sort out the problem. Thanks Navneet.H
Develop2Program & Program2Develop
-
Hi ., I have webservices method which takes parameter byte[] this byte[] parameter is compressed Dataset at client-side , Now I am Decompressing this at the server side . All this Compressing and decompressing is done to shrink the size of dataset , but now the Server pop's the error memory consumption excedded. Now, do I have any other way to compress Dataset and sent over Webservices? I did googled this problem but was enable to sort out the problem. Thanks Navneet.H
Develop2Program & Program2Develop
Navneet Hegde wrote:
do I have any other way to compress Dataset
Other than what? You haven't even said what method it is that you have tried.
--- "Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams
-
Navneet Hegde wrote:
do I have any other way to compress Dataset
Other than what? You haven't even said what method it is that you have tried.
--- "Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams
Hi ., Yea, --The client sends the request as --
byte[] Dataset2Byte; Dataset2Byte = CompressDataSet(DSet); MyService Service = new MyService.Service Service.UpdateTableData(Dataset2Byte ,tablename) //This is the Compression function used. public byte[] CompressDataSet(DataSet ds) { try { BinaryFormatter bnformat = new BinaryFormatter(); using (MemoryStream memstream = new MemoryStream()) { bnformat.Serialize(memstream, ds); byte[] bs = memstream.GetBuffer(); MemoryStream output = new MemoryStream(); GZipStream ZipIt = new GZipStream(output, CompressionMode.Compress, true); ZipIt.Write(bs, 0, bs.Length); ZipIt.Close(); return output.ToArray(); } } catch (ApplicationException ex) { MessageBox.Show(ex.Message); return null; } }
--- This is at server side webservice -----public bool UpdateTableData(byte[] byteSet, string TableName) { // here byte[] byteSet is decompressed to Dataset again } private DataSet Decompress(byte[] ds) { try { MemoryStream input = new MemoryStream(); input.Write(ds, 0, ds.Length); input.Position = 0; GZipStream Unzipit = new GZipStream(input, 0, true); MemoryStream output = new MemoryStream(); byte[] bf = new Byte[4096]; { } int read = 1; read = Unzipit.Read(bf, 0, bf.Length); while (read > 0) { output.Write(bf, 0, read); read = Unzipit.Read(bf, 0, bf.Length); } Unzipit.Close(); byte[] result = output.ToArray(); BinaryFormatter bnformat = new BinaryFormatter(); using (MemoryStream mStream = new MemoryStream(result)) { return (DataSet)bnformat.Deserialize(mStream); } } catch (Exception ex) { throw ex; } }
This throws the Error : memory consumption excedded and on server Application Event Log you read recycled mmemory consumption exceeded 60% (267MB of RAM) N -
Hi ., Yea, --The client sends the request as --
byte[] Dataset2Byte; Dataset2Byte = CompressDataSet(DSet); MyService Service = new MyService.Service Service.UpdateTableData(Dataset2Byte ,tablename) //This is the Compression function used. public byte[] CompressDataSet(DataSet ds) { try { BinaryFormatter bnformat = new BinaryFormatter(); using (MemoryStream memstream = new MemoryStream()) { bnformat.Serialize(memstream, ds); byte[] bs = memstream.GetBuffer(); MemoryStream output = new MemoryStream(); GZipStream ZipIt = new GZipStream(output, CompressionMode.Compress, true); ZipIt.Write(bs, 0, bs.Length); ZipIt.Close(); return output.ToArray(); } } catch (ApplicationException ex) { MessageBox.Show(ex.Message); return null; } }
--- This is at server side webservice -----public bool UpdateTableData(byte[] byteSet, string TableName) { // here byte[] byteSet is decompressed to Dataset again } private DataSet Decompress(byte[] ds) { try { MemoryStream input = new MemoryStream(); input.Write(ds, 0, ds.Length); input.Position = 0; GZipStream Unzipit = new GZipStream(input, 0, true); MemoryStream output = new MemoryStream(); byte[] bf = new Byte[4096]; { } int read = 1; read = Unzipit.Read(bf, 0, bf.Length); while (read > 0) { output.Write(bf, 0, read); read = Unzipit.Read(bf, 0, bf.Length); } Unzipit.Close(); byte[] result = output.ToArray(); BinaryFormatter bnformat = new BinaryFormatter(); using (MemoryStream mStream = new MemoryStream(result)) { return (DataSet)bnformat.Deserialize(mStream); } } catch (Exception ex) { throw ex; } }
This throws the Error : memory consumption excedded and on server Application Event Log you read recycled mmemory consumption exceeded 60% (267MB of RAM) NNavneet Hegde wrote:
byte[] bs = memstream.GetBuffer();
The GetBuffer method gives you the underlying array that the MemoryStream is using, including unused space. Use the ToArray method to create an array that only contains the used data.
Navneet Hegde wrote:
MemoryStream input = new MemoryStream(); input.Write(ds, 0, ds.Length); input.Position = 0;
Just do:
MemoryStream input = new MemoryStream(ds);
Navneet Hegde wrote:
GZipStream Unzipit = new GZipStream(input, 0, true);
Have you verified that
CompressionMode.Decompress
actually has the value 0?--- "Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams
-
Navneet Hegde wrote:
byte[] bs = memstream.GetBuffer();
The GetBuffer method gives you the underlying array that the MemoryStream is using, including unused space. Use the ToArray method to create an array that only contains the used data.
Navneet Hegde wrote:
MemoryStream input = new MemoryStream(); input.Write(ds, 0, ds.Length); input.Position = 0;
Just do:
MemoryStream input = new MemoryStream(ds);
Navneet Hegde wrote:
GZipStream Unzipit = new GZipStream(input, 0, true);
Have you verified that
CompressionMode.Decompress
actually has the value 0?--- "Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams
Hi Guffa., The problem for uploading huge dataset is solved for now atleast , I mean for the max dataset table having records 160000 having columns 70. What I tried is 1) Dataset.RemotingFormat = SerializationFormat.Binary; 2) I used deflateAlgorithm instead of Gzip Thanks Navneet.H
Develop2Program & Program2Develop