Methods Summary |
---|
void | addStackCallAddress(long address)Adds a stack call address for this allocation.
mStackCallAddresses.add(address);
|
public boolean | equals(java.lang.Object obj)Indicates whether some other object is "equal to" this one.
if (obj == this)
return true;
if (obj instanceof NativeAllocationInfo) {
NativeAllocationInfo mi = (NativeAllocationInfo)obj;
// quick compare of size, alloc, and stackcall size
if (mSize != mi.mSize || mAllocations != mi.mAllocations ||
mStackCallAddresses.size() != mi.mStackCallAddresses.size()) {
return false;
}
// compare the stack addresses
int count = mStackCallAddresses.size();
for (int i = 0 ; i < count ; i++) {
long a = mStackCallAddresses.get(i);
long b = mi.mStackCallAddresses.get(i);
if (a != b) {
return false;
}
}
return true;
}
return false;
|
public int | getAllocationCount()Returns the allocation count.
return mAllocations;
|
public synchronized NativeStackCallInfo | getRelevantStackCallInfo()Returns the first {@link NativeStackCallInfo} that is relevant.
A relevant NativeStackCallInfo is a stack call that is not deep in the
lower level of the libc, but the actual method that performed the allocation.
if (mIsStackCallResolved && mResolvedStackCall != null) {
Iterator<NativeStackCallInfo> sourceIterator = mResolvedStackCall.iterator();
Iterator<Long> addrIterator = mStackCallAddresses.iterator();
while (sourceIterator.hasNext() && addrIterator.hasNext()) {
long addr = addrIterator.next();
NativeStackCallInfo info = sourceIterator.next();
if (addr != 0 && info != null) {
if (isRelevant(info.getMethodName())) {
return info;
}
}
}
// couldnt find a relevant one, so we'll return the first one if it
// exists.
if (mResolvedStackCall.size() > 0)
return mResolvedStackCall.get(0);
}
return null;
|
public synchronized NativeStackCallInfo[] | getResolvedStackCall()Returns the resolved stack call.
if (mIsStackCallResolved) {
return mResolvedStackCall.toArray(new NativeStackCallInfo[mResolvedStackCall.size()]);
}
return null;
|
public int | getSize()Returns the total size of this allocation.
return mSize;
|
public java.lang.Long[] | getStackCallAddresses()Returns the stack call of this allocation as raw addresses.
return mStackCallAddresses.toArray(new Long[mStackCallAddresses.size()]);
|
private boolean | isRelevant(java.lang.String methodName)Returns true if the method name is relevant.
for (String filter : sAllocFunctionFilter) {
if (methodName.contains(filter)) {
return false;
}
}
return true;
|
public boolean | isStackCallResolved()Returns whether the stack call addresses have been resolved into
{@link NativeStackCallInfo} objects.
return mIsStackCallResolved;
|
public boolean | isZygoteChild()Returns whether the allocation happened in a child of the zygote
process.
return mIsZygoteChild;
|
public synchronized void | setResolvedStackCall(java.util.List resolvedStackCall)Sets the resolved stack call for this allocation.
If resolvedStackCall is non null then
{@link #isStackCallResolved()} will return true after this call.
if (mResolvedStackCall == null) {
mResolvedStackCall = new ArrayList<NativeStackCallInfo>();
} else {
mResolvedStackCall.clear();
}
mResolvedStackCall.addAll(resolvedStackCall);
mIsStackCallResolved = mResolvedStackCall.size() != 0;
|
public java.lang.String | toString()Returns a string representation of the object.
StringBuffer buffer = new StringBuffer();
buffer.append("Allocations: ");
buffer.append(mAllocations);
buffer.append("\n"); //$NON-NLS-1$
buffer.append("Size: ");
buffer.append(mSize);
buffer.append("\n"); //$NON-NLS-1$
buffer.append("Total Size: ");
buffer.append(mSize * mAllocations);
buffer.append("\n"); //$NON-NLS-1$
Iterator<Long> addrIterator = mStackCallAddresses.iterator();
Iterator<NativeStackCallInfo> sourceIterator = mResolvedStackCall.iterator();
while (sourceIterator.hasNext()) {
long addr = addrIterator.next();
NativeStackCallInfo source = sourceIterator.next();
if (addr == 0)
continue;
if (source.getLineNumber() != -1) {
buffer.append(String.format("\t%1$08x\t%2$s --- %3$s --- %4$s:%5$d\n", addr,
source.getLibraryName(), source.getMethodName(),
source.getSourceFile(), source.getLineNumber()));
} else {
buffer.append(String.format("\t%1$08x\t%2$s --- %3$s --- %4$s\n", addr,
source.getLibraryName(), source.getMethodName(), source.getSourceFile()));
}
}
return buffer.toString();
|