HeapProfileRequestBuilder
@RequiresApi(api = 35)
class HeapProfileRequestBuilder : ProfilingRequestBuilder
Request builder to create a request for a heap profile from ProfilingManager.
val listener = Consumer<ProfilingResult> { profilingResult -> if (profilingResult.errorCode == ProfilingResult.ERROR_NONE) { doSomethingWithMyFile(profilingResult.resultFilePath) } else { doSomethingWithFailure(profilingResult.errorCode, profilingResult.errorMessage) } } val cancellationSignal = CancellationSignal() requestProfiling( context, HeapProfileRequestBuilder() .setBufferSizeKb(1000 /* Requested buffer size in KB */) .setDurationMs(5 * 1000 /* Requested profiling duration in milliseconds */) .setTrackJavaAllocations(true) .setSamplingIntervalBytes(100 /* Requested sampling interval in bytes */) .setTag("tag" /* Caller supplied tag for identification */) .setCancellationSignal(cancellationSignal) .build(), Dispatchers.IO.asExecutor(), // Your choice of executor for the callback to occur on. listener, ) // Optionally, wait for something interesting to happen and then stop the profiling to receive // the result as is. cancellationSignal.cancel()
Summary
Public constructors |
|---|
Public functions |
|
|---|---|
HeapProfileRequestBuilder |
setBufferSizeKb(bufferSizeKb: Int)Set the buffer size in kilobytes for this profiling request. |
HeapProfileRequestBuilder |
setDurationMs(durationMs: Int)Set the duration in milliseconds for this profiling request. |
HeapProfileRequestBuilder |
setSamplingIntervalBytes(samplingIntervalBytes: Long)Set the sampling interval in bytes for this profiling request. |
HeapProfileRequestBuilder |
setTrackJavaAllocations(traceJavaAllocations: Boolean)Set whether to track Java allocations rather than native ones. |
Inherited functions |
||||||
|---|---|---|---|---|---|---|
|
Public constructors
Public functions
setBufferSizeKb
fun setBufferSizeKb(bufferSizeKb: Int): HeapProfileRequestBuilder
Set the buffer size in kilobytes for this profiling request.
setDurationMs
fun setDurationMs(durationMs: Int): HeapProfileRequestBuilder
Set the duration in milliseconds for this profiling request.
setSamplingIntervalBytes
fun setSamplingIntervalBytes(samplingIntervalBytes: Long): HeapProfileRequestBuilder
Set the sampling interval in bytes for this profiling request.
setTrackJavaAllocations
fun setTrackJavaAllocations(traceJavaAllocations: Boolean): HeapProfileRequestBuilder
Set whether to track Java allocations rather than native ones.