-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move default Hermes GC config from ReactAndroid to ReactCommon
We want to use the same GC config on iOS. We could copy it in, but I figured it would be better to move it to a shared place that can be accessed on both iOS and Android.
- Loading branch information
Showing
2 changed files
with
39 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
ReactCommon/hermes/executor/DefaultHermesGCConfigBuilder-inl.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <hermes/Public/GCConfig.h> | ||
#include <hermes/Public/RuntimeConfig.h> | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
::hermes::vm::GCConfig::Builder defaultHermesGCConfigBuilder( | ||
int64_t heapSizeMB | ||
) { | ||
namespace vm = ::hermes::vm; | ||
auto gcConfigBuilder = | ||
vm::GCConfig::Builder() | ||
.withName("RN") | ||
// For the next two arguments: avoid GC before TTI by initializing the | ||
// runtime to allocate directly in the old generation, but revert to | ||
// normal operation when we reach the (first) TTI point. | ||
.withAllocInYoung(false) | ||
.withRevertToYGAtTTI(true); | ||
if (heapSizeMB > 0) { | ||
gcConfigBuilder.withMaxHeapSize(heapSizeMB << 20); | ||
} | ||
return gcConfigBuilder; | ||
} | ||
|
||
} // namespace react | ||
} // namespace facebook |