/// <summary> /// 开辟的内存空间Buffer回收利用 /// </summary> private void RecoverMemoryInfo() { if (_memoryInfo != null) { MemoryInfoUtil.AddMemoryInfo(_memoryInfo); } _memoryInfo = null; }
/// <summary> /// 开辟了一个新的缓冲区来容纳新到来的数据. /// </summary> /// <param name="handle">clientHandle</param> /// <param name="suggestedSize">开辟的长度</param> /// <param name="state">回调参数</param> /// <returns></returns> private LibUv.BufferStruct AllocCallback(UvStreamHandle handle, int suggestedSize, object state) { if (_memoryInfo == null) { _memoryInfo = MemoryInfoUtil.GetMemoryInfo(); } return(handle.LibUv.CreateBufferStruct(_memoryInfo.AddrOfBuffer, _memoryInfo.Buffer.Length)); }