當前位置: 首頁>>代碼示例>>Java>>正文


Java Debug.dumpHprofData方法代碼示例

本文整理匯總了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;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:27,代碼來源:AndroidHeapDumper.java

示例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();
	}
}
 
開發者ID:Miracle963,項目名稱:zjdroid,代碼行數:9,代碼來源:HeapDump.java

示例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;
   }
 }
 
開發者ID:hehonghui,項目名稱:leakcanary-for-eclipse,代碼行數:22,代碼來源:AndroidHeapDumper.java

示例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());
  }
}
 
開發者ID:Laisly,項目名稱:weex,代碼行數:11,代碼來源:HprofDumperPlugin.java

示例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();
    }
}
 
開發者ID:CvvT,項目名稱:AppTroy,代碼行數:9,代碼來源:HeapDump.java

示例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;
  }
}
 
開發者ID:square,項目名稱:leakcanary,代碼行數:28,代碼來源:AndroidHeapDumper.java

示例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);
}
 
開發者ID:ROKOLabs,項目名稱:ROKO.Stickers-Android,代碼行數:45,代碼來源:CrashMonitor.java


注:本文中的android.os.Debug.dumpHprofData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。