未验证 提交 46adf73d 编写于 作者: G gaaclarke 提交者: GitHub

Made it so you can specify the old gen heap size. (#15259)

上级 a97148c4
......@@ -58,6 +58,7 @@ std::string Settings::ToString() const {
stream << "assets_path: " << assets_path << std::endl;
stream << "frame_rasterized_callback set: " << !!frame_rasterized_callback
<< std::endl;
stream << "old_gen_heap_size: " << old_gen_heap_size << std::endl;
return stream.str();
}
......
......@@ -191,6 +191,13 @@ struct Settings {
// the buffer must be as small as possible.
std::shared_ptr<const fml::Mapping> persistent_isolate_data;
/// Max size of old gen heap size in MB, or 0 for unlimited, -1 for default
/// value.
///
/// See also:
/// https://github.com/dart-lang/sdk/blob/ca64509108b3e7219c50d6c52877c85ab6a35ff2/runtime/vm/flag_list.h#L150
int64_t old_gen_heap_size = -1;
std::string ToString() const;
};
......
......@@ -7,6 +7,7 @@
#include <sys/stat.h>
#include <mutex>
#include <sstream>
#include <vector>
#include "flutter/common/settings.h"
......@@ -111,6 +112,12 @@ static const char* kDartTraceStreamsArgs[] = {
"--timeline_streams=Compiler,Dart,Debugger,Embedder,GC,Isolate,VM,API",
};
static std::string DartOldGenHeapSizeArgs(uint64_t heap_size) {
std::ostringstream oss;
oss << "--old_gen_heap_size=" << heap_size;
return oss.str();
}
constexpr char kFileUriPrefix[] = "file://";
constexpr size_t kFileUriPrefixLength = sizeof(kFileUriPrefix) - 1;
......@@ -366,6 +373,13 @@ DartVM::DartVM(std::shared_ptr<const DartVMData> vm_data,
PushBackAll(&args, kDartTraceStartupArgs, fml::size(kDartTraceStartupArgs));
}
std::string old_gen_heap_size_args;
if (settings_.old_gen_heap_size >= 0) {
old_gen_heap_size_args =
DartOldGenHeapSizeArgs(settings_.old_gen_heap_size);
args.push_back(old_gen_heap_size_args.c_str());
}
#if defined(OS_FUCHSIA)
PushBackAll(&args, kDartFuchsiaTraceArgs, fml::size(kDartFuchsiaTraceArgs));
PushBackAll(&args, kDartTraceStreamsArgs, fml::size(kDartTraceStreamsArgs));
......
......@@ -32,5 +32,15 @@ TEST_F(DartVMTest, SimpleIsolateNameServer) {
ASSERT_TRUE(ns->RemoveIsolateNameMapping("foobar"));
}
TEST_F(DartVMTest, OldGenHeapSize) {
ASSERT_FALSE(DartVMRef::IsInstanceRunning());
auto settings = CreateSettingsForFixture();
settings.old_gen_heap_size = 1024;
auto vm = DartVMRef::Create(settings);
// There is no way to introspect on the heap size so we just assert the vm was
// created.
ASSERT_TRUE(vm);
}
} // namespace testing
} // namespace flutter
......@@ -664,6 +664,7 @@ FlutterEngineResult FlutterEngineInitialize(size_t version,
settings.icu_data_path = icu_data_path;
settings.assets_path = args->assets_path;
settings.leak_vm = !SAFE_ACCESS(args, shutdown_dart_vm_when_done, false);
settings.old_gen_heap_size = SAFE_ACCESS(args, dart_old_gen_heap_size, -1);
if (!flutter::DartVM::IsRunningPrecompiledCode()) {
// Verify the assets path contains Dart 2 kernel assets.
......
......@@ -1114,6 +1114,13 @@ typedef struct {
/// absence, platforms views in the scene are ignored and Flutter renders to
/// the root surface as normal.
const FlutterCompositor* compositor;
/// Max size of the old gen heap for the Dart VM in MB, or 0 for unlimited, -1
/// for default value.
///
/// See also:
/// https://github.com/dart-lang/sdk/blob/ca64509108b3e7219c50d6c52877c85ab6a35ff2/runtime/vm/flag_list.h#L150
int64_t dart_old_gen_heap_size;
} FlutterProjectArgs;
//------------------------------------------------------------------------------
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册