Skip to content

Commit

Permalink
Update to work after app ready
Browse files Browse the repository at this point in the history
  • Loading branch information
nitsakh committed Nov 2, 2018
1 parent cad4857 commit 5510172
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions atom/common/api/atom_bindings.cc
Expand Up @@ -9,6 +9,7 @@
#include <string>
#include <vector>

#include "atom/browser/browser.h"
#include "atom/common/api/locker.h"
#include "atom/common/application_info.h"
#include "atom/common/atom_version.h"
Expand Down Expand Up @@ -223,6 +224,12 @@ v8::Local<v8::Promise> AtomBindings::GetProcessMemoryInfo(
v8::Isolate* isolate) {
scoped_refptr<util::Promise> promise = new util::Promise(isolate);

if (!Browser::Get()->is_ready()) {
promise->RejectWithErrorMessage(
"Memory Info is available only after app ready");
return promise->GetHandle();
}

memory_instrumentation::MemoryInstrumentation::GetInstance()
->RequestGlobalDumpForPid(
base::GetCurrentProcId(), std::vector<std::string>(),
Expand Down
1 change: 1 addition & 0 deletions docs/api/process.md
Expand Up @@ -171,6 +171,7 @@ currently pinned to actual physical RAM.

Returns an object giving memory usage statistics about the current process. Note
that all statistics are reported in Kilobytes.
This api should be called after app ready.

### `process.getSystemMemoryInfo()`

Expand Down

0 comments on commit 5510172

Please sign in to comment.