Comments (6)
I think I may have found a solution to this problem. My previous method was using 1 PDH Query Handle per PDH Counter. I changed my code so that now only 1 PDH Query Handle is used to contain ALL PDH Counters. This seems to cause all of the errors that were occurring to stop. It appears that PDH has an undocumented limit on how many PDH Queries can be opened simultaneously.
I updated my small test project here to reflect these changes.
So I believe that this repository can remain unchanged and that the errors I was experiencing were just due to my limited understanding of how to properly use PDH.
from win.
I'm the original committer of pdh.go
but has been quite some time since I last used it myself... Anyway, one thing I can say that everything is obviously just a wrapper around the DLL. Pretty good chance that it's just how the whole thing 'works' :)
Are you able to write up the smallest test case which is able to reproduce it? I could check it tonight, (also when there's no corporate proxy interfering).
from win.
Well I wrote up a small test case and put it in this repo.
What I am finding now, is that the PdhCollectQueryData function is actually the problem rather than the PdhValidatePath. Like I said before, the issue is very inconsistent.
To run the test program, fill the counters.txt file with a large amount of pdh counter paths (1 per line). I just ran in a command prompt: typeperf -q
then copied the output into counters.txt.
It seems to me that the problem might start occurring when too many PDH queries are opened at the same time? But i'm not sure what 'too many' is. Or how to catch that. Any insight would be very helpful.
from win.
OK I tried something. I used typeperf -q > counters.txt
and ran your test program and observed that the PdhCollectQueryData
indeed looks to be the culprit here. I got a total of 1877 counters. 456 went into error due to the PdhCollectQueryData
and 13 due to PdhAddEnglishCounter
.
I took one of the groups which failed (\Distributed Routing Table(*)
) and tried adding them all using the Windows Performance Monitor instead (perfmon.exe). They did not show up in the graph, and no error was displayed. Couldn't see anything in the event viewer as well. I'm unsure what is going on here.
I found this link but that did not seem to work on my machine (Windows 7 Enterprise).
Edit: I also tried putting a sleep of 10, 50 and 100 ms in the loop, but that did not have any effect. I got deterministic output, so it seems.
from win.
That article you found is interesting. I tried running the lodctr /r
command, but it also seemed to have no effect. It doesn't seem to me like the errors are occurring because of corruption. Rather it seems like the number of counters being gathered simultaneously has exceeded what pdh is capable of handling.
Wish there was more documentation on the win pdh stuff.
from win.
Awesome!
Perhaps it's a good idea to document this behavior or whatever into the documentation of pdh.go. I agree that PDH is rather cryptic. I therefore tried to document its usage as properly as possible back in the day. I suppose your finding is a rather useful addition.
from win.
Related Issues (20)
- I found no keybd_event() method. HOT 1
- about GetModuleFileNameEx function
- Window not created but GetLast returns success HOT 1
- Windows Server 2016 WMI performance counters memory leak
- Issue with field alignment padding of the RAWMOUSE struct
- InsertMenu function does not exist.
- Provide the method to retrieve why the system call has been failed.
- ValidateRect missing
- How to get ClassName?
- Get cursor icon as bitmap, with ability to save it.
- MIDI driver
- How to write a dynamic link library file๏ผ
- is support screen shot by dxgi?
- Add a binding for sapi.h
- How to send chinese charactor to inputbox of windows?
- Add missing synchapi.h
- Add FindWindowEx HOT 2
- How do I use win.SystemParametersInfo () to get some data?
- The Non English windows will report error in this function but the performance counter work will HOT 1
- accessibility API hard crashes on 32-bit
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from win.