[Solved] My app slows down other apps?

Everything else that doesn't fall into one of the other PB categories.
BarryG
Addict
Addict
Posts: 4173
Joined: Thu Apr 18, 2019 8:17 am

Re: My app slows down other apps?

Post by BarryG »

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.
infratec
Always Here
Always Here
Posts: 7618
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: My app slows down other apps?

Post by infratec »

https://learn.microsoft.com/en-us/windo ... 32snapshot
If the function succeeds, it returns an open handle to the specified snapshot.
No, you can do it with CallFunction, but it is more to type and your parameters are not checked.
BarryG
Addict
Addict
Posts: 4173
Joined: Thu Apr 18, 2019 8:17 am

Re: My app slows down other apps?

Post by BarryG »

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!
infratec
Always Here
Always Here
Posts: 7618
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: My app slows down other apps?

Post by infratec »

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.
BarryG
Addict
Addict
Posts: 4173
Joined: Thu Apr 18, 2019 8:17 am

Re: My app slows down other apps?

Post by BarryG »

But #INVALID_HANDLE_VALUE = -1, which is not an error and not a handle?
infratec
Always Here
Always Here
Posts: 7618
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: My app slows down other apps?

Post by infratec »

Look at my example.
I told you to check the value <> #INAVLID_HANDLE_VALUE
infratec
Always Here
Always Here
Posts: 7618
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: My app slows down other apps?

Post by infratec »

You should do:

Code: Select all

If snap <> 0 and snap <> #INVALID_HANDLE_VALUE
And inside call CloseHandle_(snap) at the end.
BarryG
Addict
Addict
Posts: 4173
Joined: Thu Apr 18, 2019 8:17 am

Re: My app slows down other apps?

Post by BarryG »

Okay, thank you. Appreciate your help again. 8)

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. :)
User avatar
spikey
Enthusiast
Enthusiast
Posts: 769
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: My app slows down other apps?

Post by spikey »

BarryG wrote: Sun Jul 14, 2024 11:32 am So I should be using FreeLibrary_() with it when done, yes?
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.
BarryG
Addict
Addict
Posts: 4173
Joined: Thu Apr 18, 2019 8:17 am

Re: My app slows down other apps?

Post by BarryG »

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.
BarryG
Addict
Addict
Posts: 4173
Joined: Thu Apr 18, 2019 8:17 am

Re: My app slows down other apps?

Post by BarryG »

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/
Fred
Administrator
Administrator
Posts: 18220
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: My app slows down other apps?

Post by Fred »

Yes, it's bad, it shouldn't be growing at all, that's probably the issue
BarryG
Addict
Addict
Posts: 4173
Joined: Thu Apr 18, 2019 8:17 am

Re: My app slows down other apps?

Post by BarryG »

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 ;) ).
DarkDragon
Addict
Addict
Posts: 2345
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: My app slows down other apps?

Post by DarkDragon »

BarryG wrote: Mon Jul 22, 2024 11:23 am Every GetDC_() should have a ReleaseDC_(), yes?
After 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.
https://learn.microsoft.com/en-us/windo ... user-getdc

It depends.
bye,
Daniel
BarryG
Addict
Addict
Posts: 4173
Joined: Thu Apr 18, 2019 8:17 am

Re: My app slows down other apps?

Post by BarryG »

DarkDragon wrote: Mon Jul 22, 2024 11:35 amIt depends.
Sh*t. :( Any harm in just releasing them if all imagery related to them is still valid?
Post Reply