summaryrefslogtreecommitdiff
path: root/tools/stats_log_api_gen/java_writer.cpp
diff options
context:
space:
mode:
authorMuhammad Qureshi <muhammadq@google.com>2019-12-04 15:38:20 -0800
committerMuhammad Qureshi <muhammadq@google.com>2019-12-10 13:27:38 -0800
commit9e829804e1e88527b6e699384570f195bc99405c (patch)
tree5b2397d6a7f62600dce2f6c50ee591a811bae168 /tools/stats_log_api_gen/java_writer.cpp
parent2ee5f0ae287d5a4b4e23b61ba48e5f747dac2b56 (diff)
Fix StatsEvent memory usage for pulled events
Add usePooledBuffer flag to the Builder which determines whether to reuse the Buffer's byte array in StatsEvent or use a copy. The build() function also calls release() on the Buffer if a copy of the Buffer's byte array is passed to StatsEvent. Also, for pushed events, release the StatsEvent object and consequently, the Buffer in StatsLog.write(StatsEvent) Fixes: 145026572 Fixes: 144126444 Test: bit FrameworksCoreTests:android.util.StatsEventTest Change-Id: I1cdaf0027b69281cb7cb6f3c8ca923d03829b4dd
Diffstat (limited to 'tools/stats_log_api_gen/java_writer.cpp')
-rw-r--r--tools/stats_log_api_gen/java_writer.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/tools/stats_log_api_gen/java_writer.cpp b/tools/stats_log_api_gen/java_writer.cpp
index 4899fbd3b669..3814f691c5f2 100644
--- a/tools/stats_log_api_gen/java_writer.cpp
+++ b/tools/stats_log_api_gen/java_writer.cpp
@@ -186,6 +186,7 @@ static int write_java_methods(
}
fprintf(out, "\n");
+ fprintf(out, "%s builder.usePooledBuffer();\n", indent.c_str());
fprintf(out, "%s StatsLog.write(builder.build());\n", indent.c_str());
// Add support for writing using Q schema if this is not the default module.