Skip to content

Commit 63b4903

Browse files
author
zhengziyi
committed
fix: Reduce memory allocation when sending jfr
1 parent b0f2651 commit 63b4903

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/asyncprofiler/AsyncProfilerDataSender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public void sendData(AsyncProfilerTask task, File dumpFile) throws IOException,
100100
GRPC_UPSTREAM_TIMEOUT, TimeUnit.SECONDS
101101
).collect(new ClientResponseObserver<AsyncProfilerData, AsyncProfilerCollectionResponse>() {
102102
ClientCallStreamObserver<AsyncProfilerData> requestStream;
103+
final byte[] buf = new byte[DATA_CHUNK_SIZE];
103104

104105
@Override
105106
public void beforeStart(ClientCallStreamObserver<AsyncProfilerData> requestStream) {
@@ -111,7 +112,6 @@ public void onNext(AsyncProfilerCollectionResponse value) {
111112
if (AsyncProfilingStatus.TERMINATED_BY_OVERSIZE.equals(value.getType())) {
112113
LOGGER.warn("JFR is too large to be received by the oap server");
113114
} else {
114-
byte[] buf = new byte[DATA_CHUNK_SIZE];
115115
try {
116116
int bytesRead;
117117
while ((bytesRead = fileInputStream.read(buf)) != -1) {

0 commit comments

Comments
 (0)