Free the resource on target device.
Change-Id: Iecb491e32ed8266cc2f866398c6f49fa5156be87
diff --git a/src/compiler_llvm/compilation_unit.cc b/src/compiler_llvm/compilation_unit.cc
index e433670..ae6e0a2 100644
--- a/src/compiler_llvm/compilation_unit.cc
+++ b/src/compiler_llvm/compilation_unit.cc
@@ -173,6 +173,12 @@
llvm::raw_string_ostream str_os(elf_image_);
bool success = MaterializeToFile(str_os, insn_set_);
LOG(INFO) << "Compilation Unit: " << elf_idx_ << (success ? " (done)" : " (failed)");
+
+ // Free the resources
+ context_.reset(NULL);
+ irb_.reset(NULL);
+ module_ = NULL;
+
return success;
}