This App is No Longer Maintained. Visit the Replacement at StrokesPlus.net

StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Active Topics
Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Bug and Issues
 Resolved Bugs and Issues
 [RESOLVED] Handles leak
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Kingron

39 Posts

Posted - 10/26/2012 :  22:15:58  Show Profile
Each gesture leak about 5 handles.
When startup S+, only used 110 handles, but after 3 days, it used about 8000 handles!

You can run Procexp to check the handles changes. Procexp can show handls usage for each process.

Rob

USA
2615 Posts

Posted - 10/26/2012 :  22:23:12  Show Profile  Visit Rob's Homepage
Sure enough, looks like each gesture creates two new handles. Will dig into it.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 10/27/2012 :  09:17:14  Show Profile  Visit Rob's Homepage
Leaks fixed in 2.3.5.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 10/27/2012 :  09:40:55  Show Profile  Visit Rob's Homepage
For those who are curious, it was a combination of process and thread handles.

Each time you hit the stroke button (in addition to successful gestures), S+ checks the window under the mouse to see if it should be ignored. One of the checks includes comparing the executable file name which involves a call to OpenProcess. As I've mentioned before, S+ was my first real C++ effort and I was unaware that the handle persisted after the function exited since the variable scope was function-only. Now, I'm calling CloseHandle once the handle is no longer needed (like 3 lines of code down).

Another series of leaks I found that were not related to this were thread handle leaks. When the Settings window is opened, it is opened in its own thread, additionally, the Lua actions and acDisplayText (separately) are fired in their own threads. In this case, I wasn't even storing the handle, simply calling CreateThread not even knowing that the thread handle would still be created and thus never closed. The threads properly return a value to exit, but the handles remained. S+ now appropriately receives the thread handle for each of these instances and calls CloseHandle.

Thanks Kingron for bringing this to my attention. While S+ may have its rough edges from the UX perspective, I consider system resource efficiency the most critical part of S+ operation and always try to make sure S+ cleans up after itself...but I learned something new today about these functions and their potential to create nasty leaks if not properly managed.
Go to Top of Page

Kingron

39 Posts

Posted - 10/28/2012 :  00:14:08  Show Profile
You're welcome.

The new version using a few of resource now. Perfect!

Now, we using laptop, and don't reboot system many days. :-), my system have some strange behavior a few days ago, so I had to check everything of my system, and found S+ using a lot of handles. Of course, my system problem not caused by S+.

Procexp is a useful tool for developers, it can view threads, stacks, mem usage, cpu usage, handles,.... and so on for system, process. Highly recommend.

For C/C++ and Windows, we should use some APIs paired, if we get something, we must to free them when unnecessary.

Java have GC mechanism, C/C++ haven't.
BTW, I don't like the GC mechanism, I'd like the developer manager the resource themselves.

Edited by - Kingron on 10/28/2012 00:35:15
Go to Top of Page

Rob

USA
2615 Posts

Posted - 10/29/2012 :  10:15:17  Show Profile  Visit Rob's Homepage
quote:
Originally posted by Kingron
BTW, I don't like the GC mechanism, I'd like the developer manager the resource themselves.


I agree!
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000