本文整理匯總了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);
}