Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi PowerShell process crashed #611

Closed
jincandev opened this issue Nov 3, 2021 · 11 comments
Closed

multi PowerShell process crashed #611

jincandev opened this issue Nov 3, 2021 · 11 comments

Comments

@jincandev
Copy link

Describe the bug
After the command executed by PowerShell under Windows 10 is completed, it does not exit PowerShell in time, resulting in full CPU during cyclic sampling and system crash

To Reproduce
Steps to reproduce the behavior:

  1. used function 'si.mem()' or 'si.fsSize()'
  2. code snippet 'si.mem()' or 'si.fsSize()'
  3. See output/error
    image

Current Output
If applicable, add output to help explain your problem.

Expected behavior
A clear and concise description of what you expected to happen.

Environment (please complete the following information):

  • systeminformation package version: 5.9.9
  • OS: Windows 10
  • Hardware: Personal Computer - Self assembled machine

Additional context
Add any other context about the problem here.

@jincandev
Copy link
Author

After testing, 'si.mem()' contains the paging file information read from the disk, and 'se.fsSize()' itself reads the disk information. This indicates that the above problems may occur as long as the disk information is read.

@sebhildebrandt
Copy link
Owner

@jcindex currently I am ill but I will try to focus on that as soon as I have recovered ...

@jincandev
Copy link
Author

@jcindex currently I am ill but I will try to focus on that as soon as I have recovered ...

Take care of your health. I will always pay attention to your reply!

@si458
Copy link
Contributor

si458 commented Nov 7, 2021

@sebhildebrandt im also noticing this sorta issue when calling users()
before the WMI refactor it was using next to no CPU usage, now every time i call it (every 5 seconds) im seeing very HIGH cpu usage from powershell and its taking about twice a long to return the results

take care of your health first though

@sebhildebrandt
Copy link
Owner

@si458 ... Thank you for your findings. Besides the general PowerShell problem... for the users() it seems that I have to make a decision between a faster implementation OR supporting UTF8 characters. As all my tests and researches showed, Windows will not give me a way to have both at the same time when using it inside node.js (which is a little bit frustrating). Anyway, I will first need to concentrate on solving the PowerShell issue here.

@si458
Copy link
Contributor

si458 commented Nov 8, 2021

@sebhildebrandt i believe the issue with the users() is because of the move to powershell because i also experience the same issue here when i look at processexplorer, nodejs is running powershell to then run cmd but it seems the powershell never closes? it stays open?

EDIT: ive had to move back to 5.9.7 because 5.9.8 was so unstable with the use of powershell and wmi

@sebhildebrandt
Copy link
Owner

@si458 I understand ... this is what I am investigating right now. I am currently trying to create a better powerShell implementation, and I hope to be able to solve this. I used the same powerShell version for quite long now in other commands without being aware of any issues (at least no one reported back to me). Will report here, as soon as I have a solution... once again thank you for reporting.

@si458
Copy link
Contributor

si458 commented Nov 8, 2021

@sebhildebrandt good luck! hope you better too, any testing, ping us 👍

@sebhildebrandt
Copy link
Owner

@si458 , @jcindex I now created a new issue that sums up related issues (windows/wmic/powershell). I guess this gives a better overview about the problems we currently have here. For this issue here I made some research and tests but I was not yet able to reproduce it. I created scripts where I run thousands of calls to men() and fsSize() not having one single powerShell instance not closing. So I need to make more research here, what the problem could be.

I was using powerShell now for 3 years in this package, and till now I did not get any reports that we have problems here. This does not mean that there isn't a problem. It is just hard to find right now. I would be happy, if you can provide a test case where I can reproduce this issue.

As we now are forced to use powerShell (wmic was dropped in windows 11), I am of course highly interested to solve this issue.

Thank you

@sebhildebrandt sebhildebrandt moved this from To do to In progress in V6 Tasks Nov 11, 2021
@sebhildebrandt
Copy link
Owner

@si458 @jcindex ... I made detailed research and it turns out that spinning up PowerShell Process is responsible for consuming resource and time. I now created a possibility to create a persistent PowerShell which then should reduce resources by 90% ...

It would be great if you can test the latest code here on GitHub: What you have to do to enable the persistent power shell:

  • on startup (if you are running in windows): si.powerShellStart();
  • and then again when shutting down the app: si.powerShellRelease();

All commands In between will then use this already pinned up powerShell.

The implementation ist still a little hacky ... but if your results are fine and this is what you would like to use, I will make a clean up! Any comments are welcome!

@sebhildebrandt
Copy link
Owner

@si458 @jcindex I testet it again here on my side and the proposed use of si.powerShellStart() improved the problem here drastically. I tried it with continuous loopes for both mentioned functions and powerShell cpu usage stays < 1% ... see the following screenshot:

Screenshot 2022-02-14 123256

Closing it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
V6 Tasks
In progress
Development

No branches or pull requests

3 participants