Skip to content

Commit

Permalink
Update API
Browse files Browse the repository at this point in the history
  • Loading branch information
nitsakh committed Oct 31, 2018
1 parent bf712de commit e3e93b9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
10 changes: 4 additions & 6 deletions atom/common/api/atom_bindings.cc
Expand Up @@ -255,13 +255,11 @@ void AtomBindings::DidReceiveMemoryDump(
if (base::GetCurrentProcId() == dump.pid()) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(env->isolate());
const auto& osdump = dump.os_dump();
#if defined(OS_LINUX)
dict.Set("residentSetBytes", osdump.resident_set_kb);
#elif defined(OS_WIN)
dict.Set("workingSetSize", osdump.resident_set_kb);
#if defined(OS_LINUX) || defined(OS_WIN)
dict.Set("residentSet", osdump.resident_set_kb);
#endif
dict.Set("privateBytes", osdump.private_footprint_kb);
dict.Set("sharedBytes", osdump.shared_footprint_kb);
dict.Set("private", osdump.private_footprint_kb);
dict.Set("shared", osdump.shared_footprint_kb);
promise->Resolve(dict.GetHandle());
resolved = true;
break;
Expand Down
8 changes: 4 additions & 4 deletions docs/api/process.md
Expand Up @@ -162,11 +162,11 @@ Returns an object with V8 heap statistics. Note that all statistics are reported

Returns `Object`:

* `residentSetBytes` Integer on _Linux_ or `workingSetSize` Integer on _Windows_ - The
amount of memory currently pinned to actual physical RAM.
* `privateBytes` Integer - The amount of memory not shared by other processes, such as
* `residentSet` Integer _Linux_ and _Windows_ - The amount of memory
currently pinned to actual physical RAM.
* `private` 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
* `shared` 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
Expand Down
11 changes: 4 additions & 7 deletions spec/api-process-spec.js
Expand Up @@ -42,15 +42,12 @@ describe('process module', () => {
it('resolves promise successfully with valid data', async () => {
const memoryInfo = await process.getProcessMemoryInfo()
expect(memoryInfo).to.be.an('object')
if (process.platform === 'linux') {
expect(memoryInfo.residentSetBytes).to.be.a('number').greaterThan(0)
if (process.platform === 'linux' || process.platform === 'windows') {
expect(memoryInfo.residentSet).to.be.a('number').greaterThan(0)
}
if (process.platform === 'windows') {
expect(memoryInfo.workingSetSize).to.be.a('number').greaterThan(0)
}
expect(memoryInfo.privateBytes).to.be.a('number').greaterThan(0)
expect(memoryInfo.private).to.be.a('number').greaterThan(0)
// Shared bytes can be zero
expect(memoryInfo.sharedBytes).to.be.a('number').greaterThan(-1)
expect(memoryInfo.shared).to.be.a('number').greaterThan(-1)
})
})

Expand Down

0 comments on commit e3e93b9

Please sign in to comment.