Methods Summary |
---|
public boolean | append(com.android.ddmlib.HeapSegment other)Append the contents of other to this segment
if it describes the segment immediately after this one.
if (canAppend(other)) {
/* Preserve the position. The mark is not preserved,
* but we don't use it anyway.
*/
int pos = mUsageData.position();
// Guarantee that we have enough room for the new data.
if (mUsageData.capacity() - mUsageData.limit() <
other.mUsageData.limit()) {
/* Grow more than necessary in case another append()
* is about to happen.
*/
int newSize = mUsageData.limit() + other.mUsageData.limit();
ByteBuffer newData = ByteBuffer.allocate(newSize * 2);
mUsageData.rewind();
newData.put(mUsageData);
mUsageData = newData;
}
// Copy the data from the other segment and restore the position.
other.mUsageData.rewind();
mUsageData.put(other.mUsageData);
mUsageData.position(pos);
// Fix this segment's header to cover the new data.
mAllocationUnitCount += other.mAllocationUnitCount;
// Mark the other segment as invalid.
other.mStartAddress = INVALID_START_ADDRESS;
other.mUsageData = null;
return true;
} else {
return false;
}
|
public boolean | canAppend(com.android.ddmlib.HeapSegment other)See if other comes immediately after this segment.
return isValid() && other.isValid() && mHeapId == other.mHeapId &&
mAllocationUnitSize == other.mAllocationUnitSize &&
getEndAddress() == other.getStartAddress();
|
public int | compareTo(com.android.ddmlib.HeapSegment other)
if (mHeapId != other.mHeapId) {
return mHeapId < other.mHeapId ? -1 : 1;
}
if (getStartAddress() != other.getStartAddress()) {
return getStartAddress() < other.getStartAddress() ? -1 : 1;
}
/* If two segments have the same start address, the rest of
* the fields should be equal. Go through the motions, though.
* Note that we re-check the components of getStartAddress()
* (mStartAddress and mOffset) to make sure that all fields in
* an equal segment are equal.
*/
if (mAllocationUnitSize != other.mAllocationUnitSize) {
return mAllocationUnitSize < other.mAllocationUnitSize ? -1 : 1;
}
if (mStartAddress != other.mStartAddress) {
return mStartAddress < other.mStartAddress ? -1 : 1;
}
if (mOffset != other.mOffset) {
return mOffset < other.mOffset ? -1 : 1;
}
if (mAllocationUnitCount != other.mAllocationUnitCount) {
return mAllocationUnitCount < other.mAllocationUnitCount ? -1 : 1;
}
if (mUsageData != other.mUsageData) {
return mUsageData.compareTo(other.mUsageData);
}
return 0;
|
public boolean | equals(java.lang.Object o)
if (o instanceof HeapSegment) {
return compareTo((HeapSegment) o) == 0;
}
return false;
|
public long | getEndAddress()
return getStartAddress() + getLength();
|
public int | getLength()
return mAllocationUnitSize * mAllocationUnitCount;
|
public com.android.ddmlib.HeapSegment$HeapSegmentElement | getNextElement(com.android.ddmlib.HeapSegment$HeapSegmentElement reuse)
try {
if (reuse != null) {
return reuse.set(this);
} else {
return new HeapSegmentElement(this);
}
} catch (BufferUnderflowException ex) {
/* Normal "end of buffer" situation.
*/
} catch (ParseException ex) {
/* Malformed data.
*/
//TODO: we should catch this in the constructor
}
return null;
|
public long | getStartAddress()
return mStartAddress + mOffset;
|
public int | hashCode()
return mHeapId * 31 +
mAllocationUnitSize * 31 +
(int) mStartAddress * 31 +
mOffset * 31 +
mAllocationUnitCount * 31 +
mUsageData.hashCode();
|
public boolean | isValid()See if this segment still contains data, and has not been
appended to another segment.
return mStartAddress != INVALID_START_ADDRESS;
|
public void | rewindElements()
if (mUsageData != null) {
mUsageData.rewind();
}
|
public java.lang.String | toString()
StringBuilder str = new StringBuilder();
str.append("HeapSegment { heap ").append(mHeapId)
.append(", start 0x")
.append(Integer.toHexString((int) getStartAddress()))
.append(", length ").append(getLength())
.append(" }");
return str.toString();
|