public static void Release(ByteArrayWriter writer) { if (!_cache.Contains(writer) && _cache.Count < 64 && writer._data.Length < 1024 * 16) //max 16kb stored { _cache.Push(writer); } }
public static ByteArrayWriter Get() { ByteArrayWriter r; if (_cache.Count > 0) { r = _cache.Pop(); } else { r = new ByteArrayWriter(); } r.Size = 0; r.Offset = 0; return(r); }