title: Can I re-use object instances to avoid allocations with protobuf-net?
body: <p><em>Context: this is based on  a question that was asked and then deleted before I could answer it - but I think it is a good question, so I've tidied it, rephrased it, and re-posted it.</em></p>
  
  <p>In a high-throughput scenario using protobuf-net, where lots of allocations are a problem (in particular for GC), is it possible to re-use objects? For example by adding a <code>Clear()</code> method?</p>
  
  <pre><code>[ProtoContract]
  public class MyDTO
  {
      [ProtoMember(1)]
      public int Foo { get; set; }
      [ProtoMember(2)]
      public string Bar { get; set; }
      [ProtoMember(3, DataFormat = DataFormat.Group)]
      public List&lt;int&gt; Values { get { return values; } }
      private readonly List&lt;int&gt; values = new List&lt;int&gt;();
  
      public void Clear()
      {
          values.Clear();
          Foo = 0;
          Bar = null;
      }
  }
  </code></pre>