mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
set old_gen_heap_size to half of available memory on iOS (#20472)
This commit is contained in:
parent
aec855d396
commit
fa33c76e01
@ -19,6 +19,7 @@ FILE: ../../../flutter/assets/directory_asset_bundle.cc
|
||||
FILE: ../../../flutter/assets/directory_asset_bundle.h
|
||||
FILE: ../../../flutter/benchmarking/benchmarking.cc
|
||||
FILE: ../../../flutter/benchmarking/benchmarking.h
|
||||
FILE: ../../../flutter/common/constants.h
|
||||
FILE: ../../../flutter/common/exported_symbols.sym
|
||||
FILE: ../../../flutter/common/settings.cc
|
||||
FILE: ../../../flutter/common/settings.h
|
||||
|
||||
7
common/constants.h
Normal file
7
common/constants.h
Normal file
@ -0,0 +1,7 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
namespace flutter {
|
||||
constexpr double kMegaByteSizeInBytes = (1 << 20);
|
||||
} // namespace flutter
|
||||
@ -6,6 +6,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "flutter/common/constants.h"
|
||||
#include "flutter/flow/layers/layer.h"
|
||||
#include "flutter/flow/paint_utils.h"
|
||||
#include "flutter/fml/logging.h"
|
||||
@ -298,12 +299,11 @@ void RasterCache::SetCheckboardCacheImages(bool checkerboard) {
|
||||
|
||||
void RasterCache::TraceStatsToTimeline() const {
|
||||
#if !FLUTTER_RELEASE
|
||||
constexpr double kMegaBytes = (1 << 20);
|
||||
FML_TRACE_COUNTER("flutter", "RasterCache", reinterpret_cast<int64_t>(this),
|
||||
"LayerCount", layer_cache_.size(), "LayerMBytes",
|
||||
EstimateLayerCacheByteSize() / kMegaBytes, "PictureCount",
|
||||
picture_cache_.size(), "PictureMBytes",
|
||||
EstimatePictureCacheByteSize() / kMegaBytes);
|
||||
EstimateLayerCacheByteSize() / kMegaByteSizeInBytes,
|
||||
"PictureCount", picture_cache_.size(), "PictureMBytes",
|
||||
EstimatePictureCacheByteSize() / kMegaByteSizeInBytes);
|
||||
|
||||
#endif // !FLUTTER_RELEASE
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
|
||||
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h"
|
||||
|
||||
#include "flutter/common/constants.h"
|
||||
#include "flutter/common/task_runners.h"
|
||||
#include "flutter/fml/mapping.h"
|
||||
#include "flutter/fml/message_loop.h"
|
||||
@ -151,6 +152,16 @@ static flutter::Settings DefaultSettingsForProcess(NSBundle* bundle = nil) {
|
||||
make_mapping_callback(kPlatformStrongDill, kPlatformStrongDillSize);
|
||||
#endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
|
||||
|
||||
// If we even support setting this e.g. from the command line or the plist,
|
||||
// we should let the user override it.
|
||||
// Otherwise, we want to set this to a value that will avoid having the OS
|
||||
// kill us. On most iOS devices, that happens somewhere near half
|
||||
// the available memory.
|
||||
// The VM expects this value to be in megabytes.
|
||||
if (settings.old_gen_heap_size <= 0) {
|
||||
settings.old_gen_heap_size = std::round([NSProcessInfo processInfo].physicalMemory * .48 /
|
||||
flutter::kMegaByteSizeInBytes);
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
@ -2,8 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <OCMock/OCMock.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#include "flutter/common/constants.h"
|
||||
#include "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
|
||||
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h"
|
||||
|
||||
FLUTTER_ASSERT_ARC
|
||||
@ -19,6 +22,13 @@ FLUTTER_ASSERT_ARC
|
||||
- (void)tearDown {
|
||||
}
|
||||
|
||||
- (void)testOldGenHeapSizeSetting {
|
||||
FlutterDartProject* project = [[FlutterDartProject alloc] init];
|
||||
int64_t old_gen_heap_size =
|
||||
std::round([NSProcessInfo processInfo].physicalMemory * .48 / flutter::kMegaByteSizeInBytes);
|
||||
XCTAssertEqual(project.settings.old_gen_heap_size, old_gen_heap_size);
|
||||
}
|
||||
|
||||
- (void)testMainBundleSettingsAreCorrectlyParsed {
|
||||
NSBundle* mainBundle = [NSBundle mainBundle];
|
||||
NSDictionary* appTransportSecurity =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user