The space we reserve in the ObjectStore before we begin an add operation.

@return long a worst case estimate of the ObjectStore space needed to add an entry
to this list.
14287
long storeSpaceForAdd() {
        return ConcurrentSubList.maximumSerializedSize() // List header
               + 3 * ConcurrentSubList.Link.maximumSerializedSize() // Current,Previous,Next links  
               + 4 * owningToken.objectStore.getAddSpaceOverhead() // Store overhead for all of the above.
               + storeSpaceForRemove(); // In case we backoutTheAdd.
    }
609191
@Override
    public long getTotalSpace() {
        checkClosed();

        if (fatType == FatType.FAT32) {
            return bs.getNrTotalSectors() * bs.getBytesPerSector();
        }

        return -1;
    }
585245
private long getSize() {
		long numSegments = 0;
		numSegments += this.availableMemory.size();
		numSegments += this.buckets.length;
		for(InMemoryPartition<T> p : this.partitions) {
			numSegments += p.getBlockCount();
			numSegments += p.numOverflowSegments;
		}
		numSegments += this.compactionMemory.getBlockCount();
		return numSegments*this.segmentSize;
	}
1320024
protected void setAllocationAllowed()
                    throws ObjectManagerException {
        final String methodName = "setAllocationAllowed";
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass, methodName, new Object[] { new Long(storeFileSizeAllocated),
                                                                new Long(storeFileSizeUsed) });

        // Users of the store should have reserved space in the store for Objects that are allocated before
        // they finally add them to the store. We have already reserved enough space for a complete replacement 
        // of the directory which also implies there is already enough space to delete any number of 
        // ManagedObjects in the store.

        // Calculate how much file space we need to continue storing ManagedObjects.
        // We make the pessimistic assumption that the entire contents of the log might need to be written 
        // to this ObjectStore.

        // We have to take into account any pending request to increase the size of the log file, because this
        // would allow applications to over commit the store if they used the extra log space when it did not 
        // exist in the Object Store.

        long storeFileSizeRequired = storeFileSizeAllocated;

        if (simulateFullReservedSize > 0) {
            // We are simulating a a full filesystem.
            allocationAllowed = false;
            reservationThreshold = 0;

        }
        else
        {
            // do we have enough space to accomdate the whole log in the store plus reserved space in the store
            long currentReservedSize = reservedSize.get();

            long pesimisticSpaceRequired = Math.max(objectManagerState.logOutput.getLogFileSize(),
                                                    objectManagerState.logOutput.getLogFileSizeRequested())
                                           + directoryReservedSize
                                           + currentReservedSize;

            long largestFreeSpace = 0;
            if (freeSpaceByLength.size() > 0) {
                largestFreeSpace = ((FreeSpace) freeSpaceByLength.last()).length;
            }

            if (pesimisticSpaceRequired <= largestFreeSpace) {
                // we can at least fit the whole log plus reserved space in the largest free space entry
                // so we are ok
                allocationAllowed = true;
            }
            else
            {
                storeFileSizeRequired = storeFileSizeUsed +
                                        pesimisticSpaceRequired;

                // See if we need to change the size of the store file.
                if (storeFileSizeRequired <= storeFileSizeAllocated) {
                    // we have allocated more than is required, its just not in the free space map yet
                    allocationAllowed = true;

                } else if (storeFileSizeRequired <= maximumStoreFileSize) {
                    // we need more than we have allocated, and that is less than the maximum allowed, try grow to the required...
                    allocationAllowed = setStoreFileSizeInternal(storeFileSizeRequired);

                } else {
                    // We need greater than the maximum allowed, make sure we have all the space we are
                    // allowed to have.
                    if (storeFileSizeAllocated < maximumStoreFileSize)
                        setStoreFileSizeInternal(maximumStoreFileSize);
                    // TODO We could still allow allocation until we really are full when the reservation scheme will catch it!
                    allocationAllowed = false;
                    // Request a checkpoint, see if we can clear some space.
                    numberOfStoreFullCheckpointsTriggered++;
                    objectManagerState.requestCheckpoint(persistent);

                } // if ( storeFileSizeRequired...

                reservationThreshold = storeFileSizeAllocated - storeFileSizeUsed - directoryReservedSize;
                reservationCheckpointThreshold = Math.min(reservationThreshold,
                                                          currentReservedSize + reservationCheckpointMaximum);
            }
        }
        // Release at least one blocked reservation request.
        if (reservationPacing) {
            synchronized (reservationPacingLock) {
                reservationPacing = false;
                reservationPacingLock.notify();
            } // synchronized (reservationPacingLock).
        }

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this,
                       cclass,
                       methodName,
                       new Object[] { new Boolean(allocationAllowed), new Long(storeFileSizeRequired) });
    }
835333
protected long getLogSpaceReserved() {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass
                        , "getLogSpaceReserved"
                          + ")");

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass
                       , "getLogSpaceReserved"
                       , "returns logSpaceReserved=" + logSpaceReserved + "(long)"
                            );
        return logSpaceReserved;
    }
934426
int getLongestChainLength() {
		int maxLen = 0;

		for (Entry<?, ?> entry : table) {
			int thisLen = 0;
			while (entry != null) {
				thisLen++;
				entry = entry.next;
			}
			maxLen = Math.max(maxLen, thisLen);
		}

		return maxLen;
	}
268142
private int estimateSegmentsBasedOnSize() {
        // the idea is that if values are huge, operations on them (and simply ser/deser)
        // could take long time, so we want more segment to minimize probablity that
        // two or more concurrent write ops will go to the same segment, and then all but one of
        // these threads will wait for long time.
        int segmentsForEntries = estimateSegmentsForEntries(entries());
        double averageValueSize = averageValueSize();
        return averageValueSize >= 1000000
                ? segmentsForEntries * 16
                : averageValueSize >= 100000
                ? segmentsForEntries * 8
                : averageValueSize >= 10000
                ? segmentsForEntries * 4
                : averageValueSize >= 1000
                ? segmentsForEntries * 2
                : segmentsForEntries;
    }
733395
@SuppressLint("DeprecatedMethod")
  public long getTotalStorageSpace(StorageType storageType) {
    ensureInitialized();

    maybeUpdateStats();

    StatFs statFS = storageType == StorageType.INTERNAL ? mInternalStatFs : mExternalStatFs;
    if (statFS != null) {
      long blockSize, totalBlocks;
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        blockSize = statFS.getBlockSizeLong();
        totalBlocks = statFS.getBlockCountLong();
      } else {
        blockSize = statFS.getBlockSize();
        totalBlocks = statFS.getBlockCount();
      }
      return blockSize * totalBlocks;
    }
    return -1;
  }
483523
public static long committedMemory() {
        long memory = 0;
        for (MemoryPoolMXBean mp : ManagementFactory.getMemoryPoolMXBeans()) {
            memory += mp.getUsage().getUsed();
        }
        return memory;
    }
1192279
public long getWorkspaceChangedSize()
   {
      long wsDelta = 0;

      Iterator<ChangesItem> changes = iterator();
      while (changes.hasNext())
      {
         wsDelta += changes.next().getWorkspaceChangedSize();
      }

      return wsDelta;
   }
774407
protected static Long getUnusedInternalStorage() {
        try {
            File path = Environment.getDataDirectory();
            StatFs stat = new StatFs(path.getPath());
            long blockSize = stat.getBlockSize();
            long availableBlocks = stat.getAvailableBlocks();
            return availableBlocks * blockSize;
        } catch (Exception e) {
            Log.e(TAG, "Error getting unused internal storage amount.", e);
            return null;
        }
    }
674642
protected long getEstimatedCacheMemoryUsage ()
    {
        long size = 0;
        Iterator<CompositedMultiFrameImage> iter = _frameCache.values().iterator();
        while (iter.hasNext()) {
            size += iter.next().getEstimatedMemoryUsage();
        }
        return size;
    }
487088
@Override
	public int getSize()
    {
        int size = 0;
        synchronized (storeLock)
        {
            if (volatileStore != null)
                size += volatileStore.size();
            if (persistentStore != null)
                size += persistentStore.size();
        }
        return size;
    }
428083
@Override
    public long getTotalSize() {
        if (totalSize == HasTotalSize.NOT_DEPLETED && !hasNext()) {
            totalSize = hasTotalSize == null ? HasTotalSize.NOT_DEPLETED : hasTotalSize.getTotalSize();
        }
        return totalSize;
    }
1092285
public java.util.List<Range> getStorageSize() {
        if (storageSize == null) {
            storageSize = new com.amazonaws.internal.SdkInternalList<Range>();
        }
        return storageSize;
    }
596512
public synchronized T get ()
    {
        while (_count == 0) {
            try { wait(); } catch (InterruptedException e) {}
        }

        // pull the object off, and clear our reference to it
        T retval = _items[_start];
        _items[_start] = null;

        _start = (_start + 1) % _size;
        _count--;

        // if we are only filling 1/8th of the space, shrink by half
        if ((_size > MIN_SHRINK_SIZE) && (_size > _suggestedSize) &&
            (_count < (_size >> 3))) shrink();

        return retval;
    }
1334230
public final long getDiscardableSize()
    {
        long result = 0;
        result = result + _storedItemManager.getStatistics().getDiscardableSize();
        result = result + _unstoredItemManager.getStatistics().getDiscardableSize();
        return result;
    }