Out of Memory Error with Encoding.UTF8.GetString
<p>This function </p>

<pre><code>Public Function UnzipString(ByVal bByteBuffer() As Byte) As String

    Dim lastBytes(3) As Byte

    Array.Copy(bByteBuffer, bByteBuffer.Length - 4, lastBytes, 0, 4)
    Dim sBufferLength As Integer = BitConverter.ToInt32(lastBytes, 0)

    Dim sBuffer(sBufferLength - 1) As Byte
    Dim ms As New System.IO.MemoryStream(bByteBuffer)
    Dim ds As New System.IO.Compression.GZipStream(ms, System.IO.Compression.CompressionMode.Decompress, True)
    ds.Read(sBuffer, 0, sBufferLength)
    Return System.Text.Encoding.UTF8.GetString(sBuffer)

End Function
</code></pre>

<p>Stops with an Out of Memory error on the Return statement, GetString call. sBuffer is pretty large, with 165 MB of (byte) data in it, but I'd still like it to work. Can anyone think of a way of getting this to work for large data sets ?</p>