You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 17, 2022. It is now read-only.
description: "Configure various V8 engine flags in order to improve the performance of your app, or to obtain more comprehensive information during debugging"
The V8 engine comes with a set of controlling flags that may be useful for fine-grained tuning. You can set these flags in the [secondary package.json configuration file]({% slug structure %}#apppackagejson). This article contains some of the available flags and short explanation on how you can use them. For a complete list of all V8 flags, see the [Flag Definitions header file](https://github.com/v8/v8/blob/6.9.247/src/flag-definitions.h) in GitHub.
11
12
12
-
V8 comes with a set of controlling flags that may be useful for a fine-grained tuning. Currently, we use `--expose_gc` flag to expose global `gc()` function which comes handy in advanced memory management scenarios. You can set these flags in `package.json` configuration file.
13
+
## Expose Garbage Collector
14
+
15
+
The `--expose_gc` flag exposes a global `gc()` function which can be helpful in [advanced memory management scenarios]({% slug memory-management %}).
13
16
14
17
```JSON
15
18
{
16
-
...
17
-
"android": {
18
-
"v8Flags": "--expose_gc"
19
-
}
20
-
...
19
+
...
20
+
"android": {
21
+
"v8Flags": "--expose_gc"
22
+
}
23
+
...
21
24
}
22
25
```
23
26
24
-
For example, here are all the flags in V8 `6.6.346`[https://github.com/v8/v8/blob/6.6.346/src/flag-definitions.h](https://github.com/v8/v8/blob/6.6.346/src/flag-definitions.h)
25
-
26
27
## Timezone Changes
27
28
28
-
For improved performance V8 keeps a cache of various values used for date / time computation. This may lead to a negative side effect for the application because changes made to the current timezone will not be reflected until the application is restarted.
29
-
30
-
While this is not a common requirement for most applications, under some circumstances this be needed. To enable this scenario, you can set the `handleTimeZoneChanges` flag:
29
+
For improved performance, V8 keeps a cache of various values used for date and time computation. This may lead to a negative side effect for the application because changes made to the current timezone will not be reflected until the application is restarted. While this is not a common requirement for most applications, there are some circumstances where this behavior might be needed. To enable this scenario, you can set the `handleTimeZoneChanges` flag:
31
30
32
31
```JSON
33
32
{
34
-
...
35
-
"android": {
36
-
"handleTimeZoneChanges": true
37
-
}
38
-
...
33
+
...
34
+
"android": {
35
+
"handleTimeZoneChanges": true
36
+
}
37
+
...
39
38
}
40
39
```
41
40
42
41
As a result, the application will register a [BroadcastReceiver](https://developer.android.com/guide/components/broadcasts) which will be responsible for the [ACTION_TIMEZONE_CHANGED](https://developer.android.com/reference/android/content/Intent.html#ACTION_TIMEZONE_CHANGED) event and automatically invalidate the corresponding cache. Subsequent calls to `new Date()` will then take into account the new timezone.
43
42
44
43
## Maximum Log Message Size
45
44
46
-
By default all messages sent to Logcat are limited to 1024 characters and larger messages are automatically truncated. This value can be controlled with the `maxLogcatObjectSize` field:
45
+
By default, all messages sent to Logcat are limited to 1024 characters and larger messages are automatically truncated. This value can be controlled with the `maxLogcatObjectSize` field:
47
46
48
47
```JSON
49
48
{
50
-
...
51
-
"android": {
52
-
"maxLogcatObjectSize": 2048
53
-
}
54
-
...
49
+
...
50
+
"android": {
51
+
"maxLogcatObjectSize": 2048
52
+
}
53
+
...
55
54
}
56
55
```
57
56
@@ -61,11 +60,11 @@ When you are using a release build there will be no logs to the console, so if y
61
60
62
61
```JSON
63
62
{
64
-
...
65
-
"android": {
66
-
"forceLog": true
67
-
}
68
-
...
63
+
...
64
+
"android": {
65
+
"forceLog": true
66
+
}
67
+
...
69
68
}
70
69
```
71
70
@@ -75,11 +74,10 @@ By default, if an exception is thrown when executing JavaScript code which is ca
75
74
76
75
```JSON
77
76
{
78
-
...
79
-
"discardUncaughtJsExceptions": true
80
-
...
77
+
...
78
+
"discardUncaughtJsExceptions": true
79
+
...
81
80
}
82
81
```
83
82
84
-
This flag works for iOS as well.
85
-
83
+
> **NOTE:** The `discardUncaughtJsExceptions` works on iOS as well. This is why in the example above the flag is not assigned to the `android` object.
0 commit comments