Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. byte[] memory consumption excedded

byte[] memory consumption excedded

Scheduled Pinned Locked Moved Web Development
helpsysadminperformancequestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Navneet Hegde
    wrote on last edited by
    #1

    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

    G 1 Reply Last reply
    0
    • N Navneet Hegde

      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

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      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

      N 1 Reply Last reply
      0
      • G Guffa

        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

        N Offline
        N Offline
        Navneet Hegde
        wrote on last edited by
        #3

        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

        G 1 Reply Last reply
        0
        • N Navneet Hegde

          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

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          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

          N 1 Reply Last reply
          0
          • G Guffa

            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

            N Offline
            N Offline
            Navneet Hegde
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups