[Solved] My app slows down other apps?
Re: My app slows down other apps?
Hi infratec. So is the way I'm currently doing it wrong ("Global kernel32=")?
Also, is "CloseHandle_(snap)" needed? Snap isn't a handle, is it? It's a return value of doing a function in an opened handle? So confused.
Also, is "CloseHandle_(snap)" needed? Snap isn't a handle, is it? It's a return value of doing a function in an opened handle? So confused.
Re: My app slows down other apps?
https://learn.microsoft.com/en-us/windo ... 32snapshot
No, you can do it with CallFunction, but it is more to type and your parameters are not checked.If the function succeeds, it returns an open handle to the specified snapshot.
Re: My app slows down other apps?
I meant "snap" when used with CallFunction() isn't a handle; it's a return value with 0 meaning error.
Anyway, I guess I will have to convert all my library calls to the way you mentioned. Thanks!
Anyway, I guess I will have to convert all my library calls to the way you mentioned. Thanks!
Re: My app slows down other apps?
According to the help it returns the value of the called function or 0 if there is no such function available.
So it returns #INVALID_HANDLE_VALUE or the open handle.
So it returns #INVALID_HANDLE_VALUE or the open handle.
Re: My app slows down other apps?
But #INVALID_HANDLE_VALUE = -1, which is not an error and not a handle?
Re: My app slows down other apps?
Look at my example.
I told you to check the value <> #INAVLID_HANDLE_VALUE
I told you to check the value <> #INAVLID_HANDLE_VALUE
Re: My app slows down other apps?
You should do:
And inside call CloseHandle_(snap) at the end.
Code: Select all
If snap <> 0 and snap <> #INVALID_HANDLE_VALUE
Re: My app slows down other apps?
Okay, thank you. Appreciate your help again. 
Also, I noticed my app has "GetModuleHandle_(0)" a lot in it. However, MSDN says this returns a handle to the module. So I should be using FreeLibrary_() with it when done, yes? I haven't been doing that.
I also had AddAtom_() without a corresponding DeleteAtom_() in there that was being called regularly. Fixed that now.
Process Explorer is working well to show me the handle count in real time while I'm debugging this issue. Some of my changes so far have stopped it rising so fast, so I'm obviously on the right track.

Also, I noticed my app has "GetModuleHandle_(0)" a lot in it. However, MSDN says this returns a handle to the module. So I should be using FreeLibrary_() with it when done, yes? I haven't been doing that.
I also had AddAtom_() without a corresponding DeleteAtom_() in there that was being called regularly. Fixed that now.
Process Explorer is working well to show me the handle count in real time while I'm debugging this issue. Some of my changes so far have stopped it rising so fast, so I'm obviously on the right track.

Re: My app slows down other apps?
Don't do that. GetModuleHandle doesn't adjust the reference count, FreeLibrary does. You'll cause problems in the targetted processes sooner or later. Stick with CloseHandle in this case.
Re: My app slows down other apps?
I seem to have fixed the handle issue (after 24 hours of running, the handle count is only 587, which is drastically down from 41811 the other day). However, the slowdown is still occurring despite this.
Looks like I still have a lot of investigating to do.

Re: My app slows down other apps?
This is so weird. I just tried using "ResMon" in Windows to suspend my app, and even though suspended, other apps (like Calc in my first post) still open and draw their GUI slowly. But if I quit my app, they open fast again. So now I'm struggling to understand why my system-suspended app STILL has an effect on other third-party app behaviour. It's like it has a hold on them somehow.
I read this -> https://superuser.com/questions/1273959 ... tasking-bu
And noticed what it said about GDI objects. Mine has 2600 of them (and growing slowly), which I assume is bad? I know how some are created (I do use "CreateDC" a lot), but is there anything specific that I should be doing other than just freeing them when done? I'm going through my code to make sure all these are done -> https://www.deleaker.com/blog/2021/12/1 ... -fix-them/
I read this -> https://superuser.com/questions/1273959 ... tasking-bu
And noticed what it said about GDI objects. Mine has 2600 of them (and growing slowly), which I assume is bad? I know how some are created (I do use "CreateDC" a lot), but is there anything specific that I should be doing other than just freeing them when done? I'm going through my code to make sure all these are done -> https://www.deleaker.com/blog/2021/12/1 ... -fix-them/
Re: My app slows down other apps?
Yes, it's bad, it shouldn't be growing at all, that's probably the issue
Re: My app slows down other apps?
Every GetDC_() should have a ReleaseDC_(), yes? I had lots of those without releasing, so I just added a release to them all.
(In my defense, a lot of those were copied codes from other people here
).
(In my defense, a lot of those were copied codes from other people here

-
- Addict
- Posts: 2345
- Joined: Mon Jun 02, 2003 9:16 am
- Location: Germany
- Contact:
Re: My app slows down other apps?
https://learn.microsoft.com/en-us/windo ... user-getdcAfter painting with a common DC, the ReleaseDC function must be called to release the DC. Class and private DCs do not have to be released. ReleaseDC must be called from the same thread that called GetDC. The number of DCs is limited only by available memory.
It depends.
bye,
Daniel
Daniel
Re: My app slows down other apps?
Sh*t.
