<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>AnalyticGal - Code Blog comments on New Memory Allocation with MemoryStream.ToArray()</title>
    <link>http://code.analyticgal.com/</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>AnalyticGal - Code Blog comments</description>
    <item>
      <title>"New Memory Allocation with MemoryStream.ToArray()" by nhughes</title>
      <description>&lt;p&gt;
If you find that you need to reduce your frequent memory allocations and deallocations, try to reduce or eliminate your use of &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemiomemorystreamclasstoarraytopic.asp"&gt;MemoryStream.ToArray()&lt;/a&gt;.  ToArray() copies the memory stream buffer into a new byte array.  You might consider using &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemiomemorystreamclassgetbuffertopic.asp"&gt;MemoryStream.GetBuffer()&lt;/a&gt; instead.  This method returns the byte array inside the MemoryStream, instead of making a copy. 
&lt;/p&gt;&lt;p&gt;
Note: GetBuffer() returns the entire array that was originally allocated, which is probably much larger than the data you wrote.  You'll need to use the MemoryStream's Length property to pick your data out of the array.
&lt;/p&gt;

</description>
      <pubDate>Thu,  5 May 2005 02:43:59 PDT</pubDate>
      <guid>&lt;a href="/articles/2005/05/05/new-memory-allocation-with-memorystream-toarray"&gt;New Memory Allocation with MemoryStream.ToArray()&lt;/a&gt;</guid>
      <link>&lt;a href="/articles/2005/05/05/new-memory-allocation-with-memorystream-toarray"&gt;New Memory Allocation with MemoryStream.ToArray()&lt;/a&gt;</link>
    </item>
  </channel>
</rss>
