/// <summary>
        /// Responds to memory pressure by simply 'discarding' the local
        /// byte array if it is not used at the moment.
        /// </summary>
        /// <param name="trimType">
        /// Kind of trimming to perform (ignored).
        /// </param>
        public void Trim(double trimType)
        {
            if (!_semaphore.Wait(1))
            {
                return;
            }

            try
            {
                _byteArraySoftRef.Clear();
            }
            finally
            {
                _semaphore.Release();
            }
        }
Example #2
0
        public override T Pop()
        {
            OOMSoftReference <T> reference = (OOMSoftReference <T>)_freeList.Dequeue();
            T value = reference.Get();

            reference.Clear();
            _spareReferences.Enqueue(reference);
            return(value);
        }