-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: This diff adds new performance API `memory`, which is a read-only property that gets the current JS heap size from native side. Note that the JSI API returns an unordered map with unknown list of memory information, which is different from the [web spec](https://fburl.com/p0vpbt33). We may enforce specific memory info type on the JSI API so that it can be properly translate to the web spec. - Update the JS spec - Update Native implementation and return memory information with JSI API `jsi::instrumentation()::getHeapInfo()` - Add native performance module to catalyst package Changelog: [General][Added] - Add performance memory API with native memory Info Reviewed By: rubennorte Differential Revision: D43137071 fbshipit-source-id: 319f1a6ba78fce61e665b00849ecf2579094af83
- Loading branch information
1 parent
ee4714e
commit 70fb2dc
Showing
5 changed files
with
102 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict | ||
* @format | ||
* @oncall react_native | ||
*/ | ||
|
||
// flowlint unsafe-getters-setters:off | ||
|
||
export type MemoryInfoLike = { | ||
jsHeapSizeLimit: ?number, | ||
totalJSHeapSize: ?number, | ||
usedJSHeapSize: ?number, | ||
}; | ||
|
||
// Read-only object with JS memory information. This is returned by the performance.memory API. | ||
export default class MemoryInfo { | ||
_jsHeapSizeLimit: ?number; | ||
_totalJSHeapSize: ?number; | ||
_usedJSHeapSize: ?number; | ||
|
||
constructor(memoryInfo: ?MemoryInfoLike) { | ||
if (memoryInfo != null) { | ||
this._jsHeapSizeLimit = memoryInfo.jsHeapSizeLimit; | ||
this._totalJSHeapSize = memoryInfo.totalJSHeapSize; | ||
this._usedJSHeapSize = memoryInfo.usedJSHeapSize; | ||
} | ||
} | ||
|
||
get jsHeapSizeLimit(): ?number { | ||
return this._jsHeapSizeLimit; | ||
} | ||
|
||
get totalJSHeapSize(): ?number { | ||
return this._totalJSHeapSize; | ||
} | ||
|
||
get usedJSHeapSize(): ?number { | ||
return this._usedJSHeapSize; | ||
} | ||
} |
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
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
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
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