Remove the 'getProcessMemoryInfo' API
* Underlying APIs have been removed in Chromium * https://chromium-review.googlesource.com/c/chromium/src/+/969089 * https://chromium-review.googlesource.com/c/chromium/src/+/953723 * https://bugs.chromium.org/p/chromium/issues/detail?id=819289 * https://github.com/electron/electron/projects/11#card-11509601
This commit is contained in:
parent
833b55107d
commit
14df89f214
9 changed files with 27 additions and 67 deletions
|
@ -55,7 +55,6 @@ void AtomBindings::BindTo(v8::Isolate* isolate, v8::Local<v8::Object> process) {
|
||||||
dict.SetMethod("hang", &Hang);
|
dict.SetMethod("hang", &Hang);
|
||||||
dict.SetMethod("log", &Log);
|
dict.SetMethod("log", &Log);
|
||||||
dict.SetMethod("getHeapStatistics", &GetHeapStatistics);
|
dict.SetMethod("getHeapStatistics", &GetHeapStatistics);
|
||||||
dict.SetMethod("getProcessMemoryInfo", &GetProcessMemoryInfo);
|
|
||||||
dict.SetMethod("getCreationTime", &GetCreationTime);
|
dict.SetMethod("getCreationTime", &GetCreationTime);
|
||||||
dict.SetMethod("getSystemMemoryInfo", &GetSystemMemoryInfo);
|
dict.SetMethod("getSystemMemoryInfo", &GetSystemMemoryInfo);
|
||||||
dict.SetMethod("getCPUUsage", base::Bind(&AtomBindings::GetCPUUsage,
|
dict.SetMethod("getCPUUsage", base::Bind(&AtomBindings::GetCPUUsage,
|
||||||
|
@ -159,26 +158,6 @@ v8::Local<v8::Value> AtomBindings::GetHeapStatistics(v8::Isolate* isolate) {
|
||||||
return dict.GetHandle();
|
return dict.GetHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
|
||||||
v8::Local<v8::Value> AtomBindings::GetProcessMemoryInfo(v8::Isolate* isolate) {
|
|
||||||
auto metrics = base::ProcessMetrics::CreateCurrentProcessMetrics();
|
|
||||||
|
|
||||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
|
||||||
dict.SetHidden("simple", true);
|
|
||||||
dict.Set("workingSetSize",
|
|
||||||
static_cast<double>(metrics->GetWorkingSetSize() >> 10));
|
|
||||||
dict.Set("peakWorkingSetSize",
|
|
||||||
static_cast<double>(metrics->GetPeakWorkingSetSize() >> 10));
|
|
||||||
|
|
||||||
size_t private_bytes, shared_bytes;
|
|
||||||
if (metrics->GetMemoryBytes(&private_bytes, &shared_bytes)) {
|
|
||||||
dict.Set("privateBytes", static_cast<double>(private_bytes >> 10));
|
|
||||||
dict.Set("sharedBytes", static_cast<double>(shared_bytes >> 10));
|
|
||||||
}
|
|
||||||
|
|
||||||
return dict.GetHandle();
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
v8::Local<v8::Value> AtomBindings::GetCreationTime(v8::Isolate* isolate) {
|
v8::Local<v8::Value> AtomBindings::GetCreationTime(v8::Isolate* isolate) {
|
||||||
auto timeValue = base::CurrentProcessInfo::CreationTime();
|
auto timeValue = base::CurrentProcessInfo::CreationTime();
|
||||||
|
|
|
@ -36,7 +36,6 @@ class AtomBindings {
|
||||||
static void Crash();
|
static void Crash();
|
||||||
static void Hang();
|
static void Hang();
|
||||||
static v8::Local<v8::Value> GetHeapStatistics(v8::Isolate* isolate);
|
static v8::Local<v8::Value> GetHeapStatistics(v8::Isolate* isolate);
|
||||||
static v8::Local<v8::Value> GetProcessMemoryInfo(v8::Isolate* isolate);
|
|
||||||
static v8::Local<v8::Value> GetCreationTime(v8::Isolate* isolate);
|
static v8::Local<v8::Value> GetCreationTime(v8::Isolate* isolate);
|
||||||
static v8::Local<v8::Value> GetSystemMemoryInfo(v8::Isolate* isolate,
|
static v8::Local<v8::Value> GetSystemMemoryInfo(v8::Isolate* isolate,
|
||||||
mate::Arguments* args);
|
mate::Arguments* args);
|
||||||
|
|
|
@ -153,7 +153,6 @@ void AtomSandboxedRendererClient::InitializeBindings(
|
||||||
b.SetMethod("getPid", &base::GetCurrentProcId);
|
b.SetMethod("getPid", &base::GetCurrentProcId);
|
||||||
b.SetMethod("getResourcesPath", &NodeBindings::GetHelperResourcesPath);
|
b.SetMethod("getResourcesPath", &NodeBindings::GetHelperResourcesPath);
|
||||||
b.SetMethod("getHeapStatistics", &AtomBindings::GetHeapStatistics);
|
b.SetMethod("getHeapStatistics", &AtomBindings::GetHeapStatistics);
|
||||||
b.SetMethod("getProcessMemoryInfo", &AtomBindings::GetProcessMemoryInfo);
|
|
||||||
b.SetMethod("getSystemMemoryInfo", &AtomBindings::GetSystemMemoryInfo);
|
b.SetMethod("getSystemMemoryInfo", &AtomBindings::GetSystemMemoryInfo);
|
||||||
b.SetMethod("getCPUUsage", base::Bind(&AtomBindings::GetCPUUsage,
|
b.SetMethod("getCPUUsage", base::Bind(&AtomBindings::GetCPUUsage,
|
||||||
base::Unretained(metrics_.get())));
|
base::Unretained(metrics_.get())));
|
||||||
|
|
|
@ -135,8 +135,6 @@ nativeImage.createFromBuffer(buffer, {
|
||||||
```js
|
```js
|
||||||
// Deprecated
|
// Deprecated
|
||||||
const info = process.getProcessMemoryInfo()
|
const info = process.getProcessMemoryInfo()
|
||||||
const privateBytes = info.privateBytes // deprecated property
|
|
||||||
const sharedBytes = info.sharedBytes // deprecated property
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## `screen`
|
## `screen`
|
||||||
|
|
|
@ -14,7 +14,6 @@ In sandboxed renderers the `process` object contains only a subset of the APIs:
|
||||||
- `crash()`
|
- `crash()`
|
||||||
- `hang()`
|
- `hang()`
|
||||||
- `getHeapStatistics()`
|
- `getHeapStatistics()`
|
||||||
- `getProcessMemoryInfo()`
|
|
||||||
- `getSystemMemoryInfo()`
|
- `getSystemMemoryInfo()`
|
||||||
- `getCPUUsage()`
|
- `getCPUUsage()`
|
||||||
- `getIOCounters()`
|
- `getIOCounters()`
|
||||||
|
@ -156,22 +155,6 @@ Returns `Object`:
|
||||||
|
|
||||||
Returns an object with V8 heap statistics. Note that all statistics are reported in Kilobytes.
|
Returns an object with V8 heap statistics. Note that all statistics are reported in Kilobytes.
|
||||||
|
|
||||||
### `process.getProcessMemoryInfo()`
|
|
||||||
|
|
||||||
Returns `Object`:
|
|
||||||
|
|
||||||
* `workingSetSize` Integer - The amount of memory currently pinned to actual physical
|
|
||||||
RAM.
|
|
||||||
* `peakWorkingSetSize` Integer - The maximum amount of memory that has ever been pinned
|
|
||||||
to actual physical RAM.
|
|
||||||
* `privateBytes` Integer - The amount of memory not shared by other processes, such as
|
|
||||||
JS heap or HTML content.
|
|
||||||
* `sharedBytes` Integer - The amount of memory shared between processes, typically
|
|
||||||
memory consumed by the Electron code itself.
|
|
||||||
|
|
||||||
Returns an object giving memory usage statistics about the current process. Note
|
|
||||||
that all statistics are reported in Kilobytes.
|
|
||||||
|
|
||||||
### `process.getSystemMemoryInfo()`
|
### `process.getSystemMemoryInfo()`
|
||||||
|
|
||||||
Returns `Object`:
|
Returns `Object`:
|
||||||
|
|
|
@ -49,7 +49,6 @@ const preloadProcess = new events.EventEmitter()
|
||||||
preloadProcess.crash = () => binding.crash()
|
preloadProcess.crash = () => binding.crash()
|
||||||
preloadProcess.hang = () => binding.hang()
|
preloadProcess.hang = () => binding.hang()
|
||||||
preloadProcess.getHeapStatistics = () => binding.getHeapStatistics()
|
preloadProcess.getHeapStatistics = () => binding.getHeapStatistics()
|
||||||
preloadProcess.getProcessMemoryInfo = () => binding.getProcessMemoryInfo()
|
|
||||||
preloadProcess.getSystemMemoryInfo = () => binding.getSystemMemoryInfo()
|
preloadProcess.getSystemMemoryInfo = () => binding.getSystemMemoryInfo()
|
||||||
preloadProcess.getCPUUsage = () => binding.getCPUUsage()
|
preloadProcess.getCPUUsage = () => binding.getCPUUsage()
|
||||||
preloadProcess.getIOCounters = () => binding.getIOCounters()
|
preloadProcess.getIOCounters = () => binding.getIOCounters()
|
||||||
|
|
|
@ -1627,7 +1627,8 @@ describe('BrowserWindow module', () => {
|
||||||
w.loadFile(path.join(fixtures, 'pages', 'window-open.html'))
|
w.loadFile(path.join(fixtures, 'pages', 'window-open.html'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('releases memory after popup is closed', (done) => {
|
// TODO(alexeykuzmin): `GetProcessMemoryInfo()` is not available starting Ch67.
|
||||||
|
xit('releases memory after popup is closed', (done) => {
|
||||||
w.destroy()
|
w.destroy()
|
||||||
w = new BrowserWindow({
|
w = new BrowserWindow({
|
||||||
show: false,
|
show: false,
|
||||||
|
|
|
@ -34,15 +34,16 @@ describe('process module', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('process.getProcessMemoryInfo()', () => {
|
// FIXME: Chromium 67 - getProcessMemoryInfo has been removed
|
||||||
it('returns process memory info object', () => {
|
// describe('process.getProcessMemoryInfo()', () => {
|
||||||
const processMemoryInfo = process.getProcessMemoryInfo()
|
// it('returns process memory info object', () => {
|
||||||
expect(processMemoryInfo.peakWorkingSetSize).to.be.a('number')
|
// const processMemoryInfo = process.getProcessMemoryInfo()
|
||||||
expect(processMemoryInfo.privateBytes).to.be.a('number')
|
// expect(processMemoryInfo.peakWorkingSetSize).to.be.a('number')
|
||||||
expect(processMemoryInfo.sharedBytes).to.be.a('number')
|
// expect(processMemoryInfo.privateBytes).to.be.a('number')
|
||||||
expect(processMemoryInfo.workingSetSize).to.be.a('number')
|
// expect(processMemoryInfo.sharedBytes).to.be.a('number')
|
||||||
})
|
// expect(processMemoryInfo.workingSetSize).to.be.a('number')
|
||||||
})
|
// })
|
||||||
|
// })
|
||||||
|
|
||||||
describe('process.getSystemMemoryInfo()', () => {
|
describe('process.getSystemMemoryInfo()', () => {
|
||||||
it('returns system memory info object', () => {
|
it('returns system memory info object', () => {
|
||||||
|
|
29
spec/fixtures/api/sandbox.html
vendored
29
spec/fixtures/api/sandbox.html
vendored
|
@ -35,20 +35,21 @@
|
||||||
await invokeGc()
|
await invokeGc()
|
||||||
ipcRenderer.send('answer', new Hello().say())
|
ipcRenderer.send('answer', new Hello().say())
|
||||||
},
|
},
|
||||||
'allocate-memory': async () => {
|
// FIXME: Chromium 67 - getProcessMemoryInfo has been removed
|
||||||
await invokeGc()
|
// 'allocate-memory': async () => {
|
||||||
const {privateBytes: bytesBeforeOpen} = process.getProcessMemoryInfo()
|
// await invokeGc()
|
||||||
let w = open('./allocate-memory.html')
|
// const {privateBytes: bytesBeforeOpen} = process.getProcessMemoryInfo()
|
||||||
await invokeGc()
|
// let w = open('./allocate-memory.html')
|
||||||
const {privateBytes: bytesAfterOpen} = process.getProcessMemoryInfo()
|
// await invokeGc()
|
||||||
w.close()
|
// const {privateBytes: bytesAfterOpen} = process.getProcessMemoryInfo()
|
||||||
w = null
|
// w.close()
|
||||||
await invokeGc()
|
// w = null
|
||||||
const {privateBytes: bytesAfterClose} = process.getProcessMemoryInfo()
|
// await invokeGc()
|
||||||
ipcRenderer.send('answer', {
|
// const {privateBytes: bytesAfterClose} = process.getProcessMemoryInfo()
|
||||||
bytesBeforeOpen, bytesAfterOpen, bytesAfterClose
|
// ipcRenderer.send('answer', {
|
||||||
})
|
// bytesBeforeOpen, bytesAfterOpen, bytesAfterClose
|
||||||
},
|
// })
|
||||||
|
// },
|
||||||
'window-events': () => {
|
'window-events': () => {
|
||||||
document.title = 'changed'
|
document.title = 'changed'
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue