public override bool FreeRAM() { lock (this) { if (!trackAllocations) { return(false); } bool any; int numToFree; if (postingsFreeCount >= postingsFreeChunk) { numToFree = postingsFreeChunk; } else { numToFree = postingsFreeCount; } any = numToFree > 0; if (any) { for (int i = postingsFreeCount - numToFree; i < postingsFreeCount; i++) { postingsFreeList[i] = null; } postingsFreeCount -= numToFree; postingsAllocCount -= numToFree; docWriter.BytesAllocated((-numToFree) * bytesPerPosting); any = true; } if (nextTermsHash != null) { any |= nextTermsHash.FreeRAM(); } return(any); } }
internal void ShrinkFreePostings(IDictionary <InvertedDocConsumerPerThread, ICollection <InvertedDocConsumerPerField> > threadsAndFields, SegmentWriteState state) { System.Diagnostics.Debug.Assert(postingsFreeCount == postingsAllocCount, "Thread.currentThread().getName()" + ": postingsFreeCount=" + postingsFreeCount + " postingsAllocCount=" + postingsAllocCount + " consumer=" + consumer); int newSize = 1; if (newSize != postingsFreeList.Length) { if (postingsFreeCount > newSize) { if (trackAllocations) { docWriter.BytesAllocated(-(postingsFreeCount - newSize) * bytesPerPosting); } postingsFreeCount = newSize; postingsAllocCount = newSize; } RawPostingList[] newArray = new RawPostingList[newSize]; Array.Copy(postingsFreeList, 0, newArray, 0, postingsFreeCount); postingsFreeList = newArray; } }
internal override bool freeRAM() { lock (this) { if (!trackAllocations) { return(false); } bool any; int numToFree; if (postingsFreeCount >= postingsFreeChunk) { numToFree = postingsFreeChunk; } else { numToFree = postingsFreeCount; } any = numToFree > 0; if (any) { SupportClass.CollectionsSupport.ArrayFill(postingsFreeList, postingsFreeCount - numToFree, postingsFreeCount, null); postingsFreeCount -= numToFree; postingsAllocCount -= numToFree; docWriter.BytesAllocated(-numToFree * bytesPerPosting); any = true; } if (nextTermsHash != null) { any |= nextTermsHash.freeRAM(); } return(any); } }