From 7bca74e53d3665bcd243d4e0277f6561c0c80271 Mon Sep 17 00:00:00 2001 From: Dimitry Ivanov Date: Mon, 22 Feb 2016 14:26:48 -0800 Subject: [PATCH] Preload public libraries on Runtime::Start() Preloading public libraries on Runtime::Start() instead of doing it in native_loader c-tor ensures that the libraries are loaded only for binaries that are using Android Runtime, and not just linking against libandroid_runtime or libart. Loading public libraries on Runtime::Start() also helps some apps to save startup time and space by ensuring that all NDK libraries are loaded and ready to use. Bug: http://b/27245894 Change-Id: I15679a72450f3d18a7dd503d0ae977cebcfd7f52 --- runtime/runtime.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/runtime/runtime.cc b/runtime/runtime.cc index eb5455a4c..9f7fabad4 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -25,6 +25,7 @@ #define ATRACE_TAG ATRACE_TAG_DALVIK #include +#include #include #include #include "base/memory_tool.h" @@ -551,6 +552,11 @@ bool Runtime::Start() { } #endif + // This line makes sure that all public native libraries + // are loaded prior to runtime start; saves app load times + // and memory. + android::PreloadPublicNativeLibraries(); + // Restore main thread state to kNative as expected by native code. Thread* self = Thread::Current(); -- 2.11.0