本文整理汇总了Java中android.os.Debug.dumpHprofData方法的典型用法代码示例。如果您正苦于以下问题:Java Debug.dumpHprofData方法的具体用法?Java Debug.dumpHprofData怎么用?Java Debug.dumpHprofData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.Debug
的用法示例。
在下文中一共展示了Debug.dumpHprofData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dumpHeap
import android.os.Debug; //导入方法依赖的package包/类
public File dumpHeap() {
if (!LeakCanaryInternals.isExternalStorageWritable()) {
Log.d(TAG, "Could not dump heap, external storage not mounted.");
}
File heapDumpFile = getHeapDumpFile();
if (heapDumpFile.exists()) {
Log.d(TAG, "Could not dump heap, previous analysis still is in progress.");
return NO_DUMP;
}
FutureResult<Toast> waitingForToast = new FutureResult();
showToast(waitingForToast);
if (waitingForToast.wait(5, TimeUnit.SECONDS)) {
Toast toast = (Toast) waitingForToast.get();
try {
Debug.dumpHprofData(heapDumpFile.getAbsolutePath());
cancelToast(toast);
return heapDumpFile;
} catch (IOException e) {
cleanup();
Log.e(TAG, "Could not perform heap dump", e);
return NO_DUMP;
}
}
Log.d(TAG, "Did not dump heap, too much time waiting for Toast.");
return NO_DUMP;
}
示例2: dumpHeap
import android.os.Debug; //导入方法依赖的package包/类
public static void dumpHeap(String filename) {
try {
Debug.dumpHprofData(filename);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例3: dumpHeap
import android.os.Debug; //导入方法依赖的package包/类
@Override
public File dumpHeap() {
if (!isExternalStorageWritable()) {
Log.d(TAG, "Could not dump heap, external storage not mounted.");
}
File heapDumpFile = getHeapDumpFile();
if (heapDumpFile.exists()) {
Log.d(TAG, "Could not dump heap, previous analysis still is in progress.");
// Heap analysis in progress, let's not put too much pressure on the device.
return null;
}
try {
Debug.dumpHprofData(heapDumpFile.getAbsolutePath());
return heapDumpFile;
} catch (IOException e) {
cleanup();
Log.e(TAG, "Could not perform heap dump", e);
// Abort heap dump
return null;
}
}
示例4: writeHprof
import android.os.Debug; //导入方法依赖的package包/类
private void writeHprof(File outputPath) throws DumpException {
try {
// Test that we can write here. dumpHprofData appears to hang if it cannot write
// to the target location on ART.
truncateAndDeleteFile(outputPath);
Debug.dumpHprofData(outputPath.getAbsolutePath());
} catch (IOException e) {
throw new DumpException("Failure writing to " + outputPath + ": " + e.getMessage());
}
}
示例5: dumpHeap
import android.os.Debug; //导入方法依赖的package包/类
public static void dumpHeap(String filename) {
try {
Debug.dumpHprofData(filename);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例6: dumpHeap
import android.os.Debug; //导入方法依赖的package包/类
@SuppressWarnings("ReferenceEquality") // Explicitly checking for named null.
@Override public File dumpHeap() {
File heapDumpFile = leakDirectoryProvider.newHeapDumpFile();
if (heapDumpFile == RETRY_LATER) {
return RETRY_LATER;
}
FutureResult<Toast> waitingForToast = new FutureResult<>();
showToast(waitingForToast);
if (!waitingForToast.wait(5, SECONDS)) {
CanaryLog.d("Did not dump heap, too much time waiting for Toast.");
return RETRY_LATER;
}
Toast toast = waitingForToast.get();
try {
Debug.dumpHprofData(heapDumpFile.getAbsolutePath());
cancelToast(toast);
return heapDumpFile;
} catch (Exception e) {
CanaryLog.d(e, "Could not dump heap");
// Abort heap dump
return RETRY_LATER;
}
}
示例7: uncaughtException
import android.os.Debug; //导入方法依赖的package包/类
@Override
public void uncaughtException(Thread thread, Throwable ex) {
try {
File dir = ctx.getExternalCacheDir();
if (dir == null || !dir.canWrite())
dir = ctx.getCacheDir();
String fileName = generateCrashName(ex.getMessage());
File log = new File(dir, fileName + ".log");
log.setReadable(true, false);
PrintWriter writer = new PrintWriter(log);
printAppInfo(writer);
writer.println();
writer.println("Exception for crash --------");
writer.println("Exception in thread- " + thread.getName() + "-" + thread.getId());
ex.printStackTrace(writer);
printDeviceInformation(ctx, writer);
printThreadStack(writer);
printLogcat(writer);
writer.close();
File hdump = null;
if (ex instanceof OutOfMemoryError) {
hdump = new File(dir, fileName + ".hprof");
hdump.setReadable(true, false);
try {
Debug.dumpHprofData(hdump.getAbsolutePath());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
hdump = null;
}
}
sendCrashReport(ctx, "Crash report for " + appName, log, hdump);
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// hand over to the default handler
if (defaultHandler != null)
defaultHandler.uncaughtException(thread, ex);
}