diff --git a/atom/common/api/atom_bindings.cc b/atom/common/api/atom_bindings.cc index 3dba3d63673c..32f05baabbb9 100644 --- a/atom/common/api/atom_bindings.cc +++ b/atom/common/api/atom_bindings.cc @@ -55,7 +55,6 @@ void AtomBindings::BindTo(v8::Isolate* isolate, v8::Local process) { dict.SetMethod("hang", &Hang); dict.SetMethod("log", &Log); dict.SetMethod("getHeapStatistics", &GetHeapStatistics); - dict.SetMethod("getProcessMemoryInfo", &GetProcessMemoryInfo); dict.SetMethod("getCreationTime", &GetCreationTime); dict.SetMethod("getSystemMemoryInfo", &GetSystemMemoryInfo); dict.SetMethod("getCPUUsage", base::Bind(&AtomBindings::GetCPUUsage, @@ -159,26 +158,6 @@ v8::Local AtomBindings::GetHeapStatistics(v8::Isolate* isolate) { return dict.GetHandle(); } -// static -v8::Local 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(metrics->GetWorkingSetSize() >> 10)); - dict.Set("peakWorkingSetSize", - static_cast(metrics->GetPeakWorkingSetSize() >> 10)); - - size_t private_bytes, shared_bytes; - if (metrics->GetMemoryBytes(&private_bytes, &shared_bytes)) { - dict.Set("privateBytes", static_cast(private_bytes >> 10)); - dict.Set("sharedBytes", static_cast(shared_bytes >> 10)); - } - - return dict.GetHandle(); -} - // static v8::Local AtomBindings::GetCreationTime(v8::Isolate* isolate) { auto timeValue = base::CurrentProcessInfo::CreationTime(); diff --git a/atom/common/api/atom_bindings.h b/atom/common/api/atom_bindings.h index ba8385c979b1..592ca08ba383 100644 --- a/atom/common/api/atom_bindings.h +++ b/atom/common/api/atom_bindings.h @@ -36,7 +36,6 @@ class AtomBindings { static void Crash(); static void Hang(); static v8::Local GetHeapStatistics(v8::Isolate* isolate); - static v8::Local GetProcessMemoryInfo(v8::Isolate* isolate); static v8::Local GetCreationTime(v8::Isolate* isolate); static v8::Local GetSystemMemoryInfo(v8::Isolate* isolate, mate::Arguments* args); diff --git a/atom/renderer/atom_sandboxed_renderer_client.cc b/atom/renderer/atom_sandboxed_renderer_client.cc index 346d181b285a..397f96e60d28 100644 --- a/atom/renderer/atom_sandboxed_renderer_client.cc +++ b/atom/renderer/atom_sandboxed_renderer_client.cc @@ -153,7 +153,6 @@ void AtomSandboxedRendererClient::InitializeBindings( b.SetMethod("getPid", &base::GetCurrentProcId); b.SetMethod("getResourcesPath", &NodeBindings::GetHelperResourcesPath); b.SetMethod("getHeapStatistics", &AtomBindings::GetHeapStatistics); - b.SetMethod("getProcessMemoryInfo", &AtomBindings::GetProcessMemoryInfo); b.SetMethod("getSystemMemoryInfo", &AtomBindings::GetSystemMemoryInfo); b.SetMethod("getCPUUsage", base::Bind(&AtomBindings::GetCPUUsage, base::Unretained(metrics_.get()))); diff --git a/docs/api/breaking-changes.md b/docs/api/breaking-changes.md index f0e54c3b73c1..2e28a5f1b856 100644 --- a/docs/api/breaking-changes.md +++ b/docs/api/breaking-changes.md @@ -135,8 +135,6 @@ nativeImage.createFromBuffer(buffer, { ```js // Deprecated const info = process.getProcessMemoryInfo() -const privateBytes = info.privateBytes // deprecated property -const sharedBytes = info.sharedBytes // deprecated property ``` ## `screen` diff --git a/docs/api/process.md b/docs/api/process.md index 1f6b20d2f25c..691238a737a4 100644 --- a/docs/api/process.md +++ b/docs/api/process.md @@ -14,7 +14,6 @@ In sandboxed renderers the `process` object contains only a subset of the APIs: - `crash()` - `hang()` - `getHeapStatistics()` -- `getProcessMemoryInfo()` - `getSystemMemoryInfo()` - `getCPUUsage()` - `getIOCounters()` @@ -156,22 +155,6 @@ Returns `Object`: 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()` Returns `Object`: diff --git a/lib/sandboxed_renderer/init.js b/lib/sandboxed_renderer/init.js index afb505490e65..9569ec49c915 100644 --- a/lib/sandboxed_renderer/init.js +++ b/lib/sandboxed_renderer/init.js @@ -49,7 +49,6 @@ const preloadProcess = new events.EventEmitter() preloadProcess.crash = () => binding.crash() preloadProcess.hang = () => binding.hang() preloadProcess.getHeapStatistics = () => binding.getHeapStatistics() -preloadProcess.getProcessMemoryInfo = () => binding.getProcessMemoryInfo() preloadProcess.getSystemMemoryInfo = () => binding.getSystemMemoryInfo() preloadProcess.getCPUUsage = () => binding.getCPUUsage() preloadProcess.getIOCounters = () => binding.getIOCounters() diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 0b579fd8d972..65ba314024a9 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -1627,7 +1627,8 @@ describe('BrowserWindow module', () => { 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 = new BrowserWindow({ show: false, diff --git a/spec/api-process-spec.js b/spec/api-process-spec.js index ad8f1faea142..2b07c407a21f 100644 --- a/spec/api-process-spec.js +++ b/spec/api-process-spec.js @@ -34,15 +34,16 @@ describe('process module', () => { }) }) - describe('process.getProcessMemoryInfo()', () => { - it('returns process memory info object', () => { - const processMemoryInfo = process.getProcessMemoryInfo() - expect(processMemoryInfo.peakWorkingSetSize).to.be.a('number') - expect(processMemoryInfo.privateBytes).to.be.a('number') - expect(processMemoryInfo.sharedBytes).to.be.a('number') - expect(processMemoryInfo.workingSetSize).to.be.a('number') - }) - }) + // FIXME: Chromium 67 - getProcessMemoryInfo has been removed + // describe('process.getProcessMemoryInfo()', () => { + // it('returns process memory info object', () => { + // const processMemoryInfo = process.getProcessMemoryInfo() + // expect(processMemoryInfo.peakWorkingSetSize).to.be.a('number') + // expect(processMemoryInfo.privateBytes).to.be.a('number') + // expect(processMemoryInfo.sharedBytes).to.be.a('number') + // expect(processMemoryInfo.workingSetSize).to.be.a('number') + // }) + // }) describe('process.getSystemMemoryInfo()', () => { it('returns system memory info object', () => { diff --git a/spec/fixtures/api/sandbox.html b/spec/fixtures/api/sandbox.html index af796ebc988b..e745e7a62d42 100644 --- a/spec/fixtures/api/sandbox.html +++ b/spec/fixtures/api/sandbox.html @@ -35,20 +35,21 @@ await invokeGc() ipcRenderer.send('answer', new Hello().say()) }, - 'allocate-memory': async () => { - await invokeGc() - const {privateBytes: bytesBeforeOpen} = process.getProcessMemoryInfo() - let w = open('./allocate-memory.html') - await invokeGc() - const {privateBytes: bytesAfterOpen} = process.getProcessMemoryInfo() - w.close() - w = null - await invokeGc() - const {privateBytes: bytesAfterClose} = process.getProcessMemoryInfo() - ipcRenderer.send('answer', { - bytesBeforeOpen, bytesAfterOpen, bytesAfterClose - }) - }, + // FIXME: Chromium 67 - getProcessMemoryInfo has been removed + // 'allocate-memory': async () => { + // await invokeGc() + // const {privateBytes: bytesBeforeOpen} = process.getProcessMemoryInfo() + // let w = open('./allocate-memory.html') + // await invokeGc() + // const {privateBytes: bytesAfterOpen} = process.getProcessMemoryInfo() + // w.close() + // w = null + // await invokeGc() + // const {privateBytes: bytesAfterClose} = process.getProcessMemoryInfo() + // ipcRenderer.send('answer', { + // bytesBeforeOpen, bytesAfterOpen, bytesAfterClose + // }) + // }, 'window-events': () => { document.title = 'changed' },