Merge "Release dummy MemMaps corresponding to dlopen."
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index 225fee0..ad5741e 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -301,15 +301,17 @@
             uint8_t* vaddr = reinterpret_cast<uint8_t*>(info->dlpi_addr +
                                                         info->dlpi_phdr[i].p_vaddr);
             size_t memsz = info->dlpi_phdr[i].p_memsz;
-            MemMap::MapDummy(info->dlpi_name, vaddr, memsz);
+            MemMap* mmap = MemMap::MapDummy(info->dlpi_name, vaddr, memsz);
+            context->dlopen_mmaps_->push_back(std::unique_ptr<MemMap>(mmap));
           }
         }
         return 1;  // Stop iteration and return 1 from dl_iterate_phdr.
       }
       return 0;  // Continue iteration and return 0 from dl_iterate_phdr when finished.
     }
-    const uint8_t* begin_;
-  } context = { begin_ };
+    const uint8_t* const begin_;
+    std::vector<std::unique_ptr<MemMap>>* const dlopen_mmaps_;
+  } context = { begin_, &dlopen_mmaps_ };
 
   if (dl_iterate_phdr(dl_iterate_context::callback, &context) == 0) {
     PrintFileToLog("/proc/self/maps", LogSeverity::WARNING);
diff --git a/runtime/oat_file.h b/runtime/oat_file.h
index c58b029..1a782de 100644
--- a/runtime/oat_file.h
+++ b/runtime/oat_file.h
@@ -321,6 +321,9 @@
   // dlopen handle during runtime.
   void* dlopen_handle_;
 
+  // Dummy memory map objects corresponding to the regions mapped by dlopen.
+  std::vector<std::unique_ptr<MemMap>> dlopen_mmaps_;
+
   // Owning storage for the OatDexFile objects.
   std::vector<const OatDexFile*> oat_dex_files_storage_;