Skip to content

Add option to collect memory information from processes - #11

Merged
Daniel Imms (Tyriar) merged 4 commits into
masterfrom
rmacfarlane/memory
Mar 16, 2018
Merged

Daniel Imms (Tyriar) merged 4 commits into
masterfrom
rmacfarlane/memory

Conversation

@RMacfarlane

Copy link
Copy Markdown
Contributor

Adds optional flags parameter to control what information is fetched about a process. When memory bit is set, reports memory usage for each process in bytes.

Comment thread lib/index.js
}

function getProcessTree(rootPid, callback) {
function getProcessTree(rootPid, callback, flags) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need a corresponding change in the typings file

Comment thread src/addon.cc Outdated
return;
}

// Flags is an optional parameter. By default, all options for included process data are off.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it a mandatory parameter in the C++ side and use flags || 0 on JS side to simplify things.

Comment thread test.js
native.getProcessList((list) => {
assert.equal(list.some((p => p.memory !== 0)), true);
done();
}, 1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the flags enum here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, since this is a js file. I can make a separate change to move to using typescript

Comment thread test.js Outdated

// Memory should be a number when flag is set
native.getProcessList((list) => {
assert.equal(list.some((p => p.memory !== 0)), true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

> 0 to be safer since !== 0 will be true when it's undefined.

Comment thread typings/windows-process-tree.d.ts Outdated
}

function get(rootPid: number, callback: (tree: ProcessTreeNode) => void): void;
function get(rootPid: number, callback: (tree: ProcessTreeNode) => void, flag?: ProcessDataFlag): void;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's call this flags

@Tyriar
Daniel Imms (Tyriar) merged commit 9dde6e7 into master Mar 16, 2018
@Tyriar
Daniel Imms (Tyriar) deleted the rmacfarlane/memory branch March 16, 2018 15:24
@Tyriar Daniel Imms (Tyriar) added this to the 0.2.0 milestone Mar 16, 2018
Volodymyr M (vmihdal) pushed a commit to vmihdal/vscode-windows-process-tree that referenced this pull request Aug 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants