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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 3000623002: [kernel] Free memory for kernel data. (Closed)
Patch Set: Remove commented out code Created 3 years, 4 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
Index: runtime/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index ea47c97744ba30ba1cd2fe184bc1970070ee1c31..31c7dcdd184e9294f36a819423a5172a429bc961 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -5054,11 +5054,15 @@ static void CompileSource(Thread* thread,
static Dart_Handle LoadKernelProgram(Thread* T,
const String& url,
void* kernel) {
- // NOTE: Now the VM owns the [kernel_program] memory! Currently we do not
- // free it because (similar to the token stream) it will be used to repeatedly
- // run the `kernel::FlowGraphBuilder()`.
- kernel::KernelReader reader(reinterpret_cast<kernel::Program*>(kernel));
+ // NOTE: Now the VM owns the [kernel_program] memory!
+ // We will promptly delete it when done.
+ kernel::Program* program = reinterpret_cast<kernel::Program*>(kernel);
+ kernel::KernelReader reader(program);
const Object& tmp = reader.ReadProgram();
+ delete program;
+ program = NULL;
Kevin Millikin (Google) 2017/08/14 06:20:50 program = NULL and kernel = NULL don't seem necess
jensj 2017/08/14 08:38:12 Done.
+ kernel = NULL;
+
if (tmp.IsError()) {
return Api::NewHandle(T, tmp.raw());
}
@@ -5236,12 +5240,15 @@ DART_EXPORT Dart_Handle Dart_LoadKernel(void* kernel_program) {
CHECK_CALLBACK_STATE(T);
CHECK_COMPILATION_ALLOWED(I);
- // NOTE: Now the VM owns the [kernel_program] memory! Currently we do not
- // free it because (similar to the token stream) it will be used to repeatedly
- // run the `kernel::FlowGraphBuilder()`.
- kernel::KernelReader reader(
- reinterpret_cast<kernel::Program*>(kernel_program));
+ // NOTE: Now the VM owns the [kernel_program] memory!
+ // We will promptly delete it when done.
+ kernel::Program* program = reinterpret_cast<kernel::Program*>(kernel_program);
+ kernel::KernelReader reader(program);
const Object& tmp = reader.ReadProgram();
+ delete program;
+ program = NULL;
Kevin Millikin (Google) 2017/08/14 06:20:50 Likewise, here I don't think setting them to NULL
jensj 2017/08/14 08:38:12 Done.
+ kernel_program = NULL;
+
if (tmp.IsError()) {
return Api::NewHandle(T, tmp.raw());
}

Powered by Google App Engine
This is Rietveld 408576698