Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Unified Diff: runtime/vm/benchmark_test.cc

Issue 2629533002: Fix leak of message snapshot buffer when attempting to send an illegal object. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/vmservice.cc ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/benchmark_test.cc
diff --git a/runtime/vm/benchmark_test.cc b/runtime/vm/benchmark_test.cc
index e2f8790357fc229a2466f3a964be18356b71fa99..efe1223e82132d0ba46e666154bae3b4acc910a0 100644
--- a/runtime/vm/benchmark_test.cc
+++ b/runtime/vm/benchmark_test.cc
@@ -491,6 +491,11 @@ static uint8_t* malloc_allocator(uint8_t* ptr,
}
+static void malloc_deallocator(uint8_t* ptr) {
+ free(ptr);
+}
+
+
BENCHMARK_SIZE(CoreSnapshotSize) {
const char* kScriptChars =
"import 'dart:async';\n"
@@ -607,6 +612,7 @@ static uint8_t* message_allocator(uint8_t* ptr,
intptr_t new_size) {
return message_buffer;
}
+static void message_deallocator(uint8_t* ptr) {}
BENCHMARK(SerializeNull) {
@@ -617,7 +623,8 @@ BENCHMARK(SerializeNull) {
timer.Start();
for (intptr_t i = 0; i < kLoopCount; i++) {
StackZone zone(thread);
- MessageWriter writer(&buffer, &message_allocator, true);
+ MessageWriter writer(&buffer, &message_allocator, &message_deallocator,
+ true);
writer.WriteMessage(null_object);
intptr_t buffer_len = writer.BytesWritten();
@@ -639,7 +646,8 @@ BENCHMARK(SerializeSmi) {
timer.Start();
for (intptr_t i = 0; i < kLoopCount; i++) {
StackZone zone(thread);
- MessageWriter writer(&buffer, &message_allocator, true);
+ MessageWriter writer(&buffer, &message_allocator, &message_deallocator,
+ true);
writer.WriteMessage(smi_object);
intptr_t buffer_len = writer.BytesWritten();
@@ -664,7 +672,7 @@ BENCHMARK(SimpleMessage) {
timer.Start();
for (intptr_t i = 0; i < kLoopCount; i++) {
StackZone zone(thread);
- MessageWriter writer(&buffer, &malloc_allocator, true);
+ MessageWriter writer(&buffer, &malloc_allocator, &malloc_deallocator, true);
writer.WriteMessage(array_object);
intptr_t buffer_len = writer.BytesWritten();
@@ -698,7 +706,7 @@ BENCHMARK(LargeMap) {
timer.Start();
for (intptr_t i = 0; i < kLoopCount; i++) {
StackZone zone(thread);
- MessageWriter writer(&buffer, &malloc_allocator, true);
+ MessageWriter writer(&buffer, &malloc_allocator, &malloc_deallocator, true);
writer.WriteMessage(map);
intptr_t buffer_len = writer.BytesWritten();
« no previous file with comments | « runtime/lib/vmservice.cc ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698