Example #1
0
        /// <summary>
        /// Frees the allocated memory.
        /// </summary>
        private void FreeBuffers()
        {
            if (this.memHeaders != IntPtr.Zero)
            {
                MemoryUtil.Free(this.memHeaders);
                this.memHeaders = IntPtr.Zero;
            }

            if (this.memBuffers != IntPtr.Zero)
            {
                MemoryUtil.Free(this.memBuffers);
                this.memBuffers = IntPtr.Zero;
            }

            var totalLength = (MemoryUtil.SizeOfMidiHeader + this.BufferSize) * this.BufferCount;

            if (totalLength > 0)
            {
                GC.RemoveMemoryPressure(totalLength);
            }
        }