Release dummy MemMaps corresponding to dlopen.
This fixes memory leak.
Change-Id: I857f078e8559a56b2d10dd081256c41ab28c8ec6
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);