KeyedWeakReference(Object referent, String key, String name, ReferenceQueue<Object> referenceQueue) { super(checkNotNull(referent, "referent"), checkNotNull(referenceQueue, "referenceQueue")); this.key = checkNotNull(key, "key"); this.name = checkNotNull(name, "name"); } }
public Builder excludedRefs(ExcludedRefs excludedRefs) { this.excludedRefs = checkNotNull(excludedRefs, "excludedRefs"); return this; }
public Builder heapDumpFile(File heapDumpFile) { this.heapDumpFile = checkNotNull(heapDumpFile, "heapDumpFile"); return this; }
public Builder referenceName(String referenceName) { this.referenceName = checkNotNull(referenceName, "referenceName"); return this; }
public Builder referenceKey(String referenceKey) { this.referenceKey = checkNotNull(referenceKey, "referenceKey"); return this; }
RefWatcher(WatchExecutor watchExecutor, DebuggerControl debuggerControl, GcTrigger gcTrigger, HeapDumper heapDumper, HeapDump.Listener heapdumpListener, HeapDump.Builder heapDumpBuilder) { this.watchExecutor = checkNotNull(watchExecutor, "watchExecutor"); this.debuggerControl = checkNotNull(debuggerControl, "debuggerControl"); this.gcTrigger = checkNotNull(gcTrigger, "gcTrigger"); this.heapDumper = checkNotNull(heapDumper, "heapDumper"); this.heapdumpListener = checkNotNull(heapdumpListener, "heapdumpListener"); this.heapDumpBuilder = heapDumpBuilder; retainedKeys = new CopyOnWriteArraySet<>(); queue = new ReferenceQueue<>(); }
public HeapDump build() { checkNotNull(excludedRefs, "excludedRefs"); checkNotNull(heapDumpFile, "heapDumpFile"); checkNotNull(referenceKey, "referenceKey"); checkNotNull(reachabilityInspectorClasses, "reachabilityInspectorClasses"); return new HeapDump(this); } }
public Builder reachabilityInspectorClasses( List<Class<? extends Reachability.Inspector>> reachabilityInspectorClasses) { checkNotNull(reachabilityInspectorClasses, "reachabilityInspectorClasses"); this.reachabilityInspectorClasses = unmodifiableList(new ArrayList<>(reachabilityInspectorClasses)); return this; }
public ServiceHeapDumpListener(@NonNull final Context context, @NonNull final Class<? extends AbstractAnalysisResultService> listenerServiceClass) { this.listenerServiceClass = checkNotNull(listenerServiceClass, "listenerServiceClass"); this.context = checkNotNull(context, "context").getApplicationContext(); }
@Override public BuilderWithParams instanceField(String className, String fieldName) { checkNotNull(className, "className"); checkNotNull(fieldName, "fieldName"); Map<String, ParamsBuilder> excludedFields = fieldNameByClassName.get(className); if (excludedFields == null) { excludedFields = new LinkedHashMap<>(); fieldNameByClassName.put(className, excludedFields); } lastParams = new ParamsBuilder("field " + className + "#" + fieldName); excludedFields.put(fieldName, lastParams); return this; }
@Override public BuilderWithParams staticField(String className, String fieldName) { checkNotNull(className, "className"); checkNotNull(fieldName, "fieldName"); Map<String, ParamsBuilder> excludedFields = staticFieldNameByClassName.get(className); if (excludedFields == null) { excludedFields = new LinkedHashMap<>(); staticFieldNameByClassName.put(className, excludedFields); } lastParams = new ParamsBuilder("static field " + className + "#" + fieldName); excludedFields.put(fieldName, lastParams); return this; }
/** Ignores all fields and static fields of all subclasses of the provided class name. */ @Override public BuilderWithParams clazz(String className) { checkNotNull(className, "className"); lastParams = new ParamsBuilder("any subclass of " + className); classNames.put(className, lastParams); return this; }
@Override public BuilderWithParams thread(String threadName) { checkNotNull(threadName, "threadName"); lastParams = new ParamsBuilder("any threads named " + threadName); threadNames.put(threadName, lastParams); return this; }
@Override public void analyze(@NonNull HeapDump heapDump) { checkNotNull(heapDump, "heapDump"); HeapAnalyzerService.runAnalysis(context, heapDump, listenerServiceClass); } }
/** * Watches the provided references and checks if it can be GCed. This method is non blocking, * the check is done on the {@link WatchExecutor} this {@link RefWatcher} has been constructed * with. * * @param referenceName An logical identifier for the watched object. */ public void watch(Object watchedReference, String referenceName) { if (this == DISABLED) { return; } checkNotNull(watchedReference, "watchedReference"); checkNotNull(referenceName, "referenceName"); final long watchStartNanoTime = System.nanoTime(); String key = UUID.randomUUID().toString(); retainedKeys.add(key); final KeyedWeakReference reference = new KeyedWeakReference(watchedReference, key, referenceName, queue); ensureGoneAsync(watchStartNanoTime, reference); }
/** Can be overridden to report leaks in a different way or do additional reporting. */ protected void reportLeaks(@NonNull InstrumentationLeakResults results) { if (!results.detectedLeaks.isEmpty()) { String message = checkNotNull(buildLeakDetectedMessage(results.detectedLeaks), "buildLeakDetectedMessage"); bundle.putString(InstrumentationResultPrinter.REPORT_KEY_STACK, message); getInstrumentation().sendStatus(REPORT_VALUE_RESULT_FAILURE, bundle); } }
checkNotNull(stringObject, "stringObject"); Instance instance = (Instance) stringObject; List<ClassInstance.FieldValue> values = classInstanceValues(instance); checkNotNull(count, "count"); if (count == 0) { return ""; checkNotNull(value, "value"); checkNotNull(offset, "offset");
KeyedWeakReference(Object referent, String key, String name, ReferenceQueue<Object> referenceQueue) { super(checkNotNull(referent, "referent"), checkNotNull(referenceQueue, "referenceQueue")); this.key = checkNotNull(key, "key"); this.name = checkNotNull(name, "name"); } }
public HeapDump(File heapDumpFile, String referenceKey, String referenceName, ExcludedRefs excludedRefs, long watchDurationMs, long gcDurationMs, long heapDumpDurationMs) { this.heapDumpFile = checkNotNull(heapDumpFile, "heapDumpFile"); this.referenceKey = checkNotNull(referenceKey, "referenceKey"); this.referenceName = checkNotNull(referenceName, "referenceName"); this.excludedRefs = checkNotNull(excludedRefs, "excludedRefs"); this.watchDurationMs = watchDurationMs; this.gcDurationMs = gcDurationMs; this.heapDumpDurationMs = heapDumpDurationMs; } }
RefWatcher(WatchExecutor watchExecutor, DebuggerControl debuggerControl, GcTrigger gcTrigger, HeapDumper heapDumper, HeapDump.Listener heapdumpListener, ExcludedRefs excludedRefs) { this.watchExecutor = checkNotNull(watchExecutor, "watchExecutor"); this.debuggerControl = checkNotNull(debuggerControl, "debuggerControl"); this.gcTrigger = checkNotNull(gcTrigger, "gcTrigger"); this.heapDumper = checkNotNull(heapDumper, "heapDumper"); this.heapdumpListener = checkNotNull(heapdumpListener, "heapdumpListener"); this.excludedRefs = checkNotNull(excludedRefs, "excludedRefs"); retainedKeys = new CopyOnWriteArraySet<>(); queue = new ReferenceQueue<>(); }