New client appears to have a Handle Leak

Case number:671071-2004487
Topic:Game: Other
Opened by:Susume
Status:Open
Type:Bug
Opened on:Wednesday, November 22, 2017 - 01:02
Last modified:Friday, February 22, 2019 - 20:18

Since taking the new devprev a few days ago, I have noticed game clients growing very sluggish after they have been running for 12 or more hours. I also notice an increasing number of open handles associated with each client as time goes by. Every time a script calls a foldit tool (wiggle, shake, rebuild) it appears the handle count goes up by one. These handles are not given back after the script is terminated. A new client has about 470 handles; the one I am looking at now that has been running for six hours has 22,000 handles.

There was an apparent handle leak a year or so ago, no idea if it is related: https://fold.it/portal/node/2002316

(Wed, 11/22/2017 - 01:02  |  5 comments)


Susume's picture
User offline. Last seen 20 hours 21 min ago. Offline
Joined: 10/02/2011
Topic: General » Game: Other
Type: Suggestion » Bug

Bleh, can't remember to set the category/type.

jeff101's picture
User offline. Last seen 15 hours 48 min ago. Offline
Joined: 04/20/2012
Groups: Go Science
I still experience Handle Leaks on Foldit clients in Windows.
Using Task Manager, I list the number of Handles for each 
Foldit client and usually see this number rising vs time.
It seems that having a high number of Handles slows down 
a client.

I suspect that some Recipes make the # of Handles rise
faster than others, but I don't have good stats on this.
Does anyone have a sense which Recipes/tools/commands 
cause the # of Handles to rise fastest? Do you have any
tips for writing Recipes that make the # of Handles
rise more slowly?

In my C-programming days, I often had to worry about memory
use increasing vs time. If the memory use increased too much,
it would slow down my programs. See below for some details:
https://fold.it/portal/node/997610#comment-32742  
Anyway, in LUA, do we have to worry about memory use increasing 
vs time? I was reading the other day about LUA memory leaks. 
It seemed that if you did something like below:

grid={}
for k1=1,100 do
   grid[k1]={}
   for k2=1,100 do
      grid[k1][k2]=0
   end
end

you should later do like below:

grid=nil

to free the memory used by grid.

I also saw use of commands like below:

-- measure the memory in use:
cg1=collectgarbage("count") 
gc1a,gc1b=gcinfo()
--
-- clear the unused memory:
collectgarbage() 
--
-- measure the memory in use:
cg2=collectgarbage("count")
gc2a,gc2b=gcinfo()
--
-- report the results:
print(string.format('Memory/kB=%f=%f -> %f=%f while Threshold/kB=%f -> %f.',
   cg1,gc1a,cg2,gc2a,gc1b,gc2b))

but when I tried them in a Foldit LUA recipe,
cg1=collectgarbage("count") 
gave the message "attempt to call global 'collectgarbage' (a nil value)", and
gc1a,gc1b=gcinfo()
gave the message "attempt to call global 'gcinfo' (a nil value)".

Does anyone know how to make gcinfo and collectgarbage work 
in a LUA recipe? Are there other LUA commands we can use instead
to monitor memory or Handles in use? Is there a command that will 
decrease the # of Handles a client is using?

Thanks!
brow42's picture
User offline. Last seen 3 weeks 4 days ago. Offline
Joined: 09/19/2011
Groups: None

After some security consideration, Tlaloc decided to only include a subset of the standard LUA library. Also, there is no pointer to the global table, so you can't look to see what is defined.

The almost complete list of top level functions is here:

https://foldit.fandom.com/wiki/Lua_Standard_Libraries

LociOiling's picture
User offline. Last seen 1 hour 1 min ago. Offline
Joined: 12/27/2012
Groups: Beta Folders

Old feedback, nothing seems to have changed.

I don't think the previous handle leak feedback was ever resolved, either: https://fold.it/portal/node/200231

The Foldit implementation of Lua doesn't include "system" functions like gcinfo, and there's no workaround, as far as I know. Likewise, you can't directly read and write files in a Foldit recipe, those functions just aren't on the list.

From what I remember previously, the leak may have something do with starting new threads. Apparently, in Windows, if you start a new thread in the wrong spot, the thread handle never gets cleaned up. So, most likely the leak occurs at the level of Windows calls, and doesn't involve Lua. Without source code, it seems difficult to take it further than that.

rmoretti's picture
User offline. Last seen 1 week 6 days ago. Offline
Joined: 01/15/2010
Groups: None

Thanks for the bug report. I think I've tracked this down, and the next devprev releases should have a fix which hopefully addresses the bulk of the handle leaks.

Sitemap

Developed by: UW Center for Game Science, UW Institute for Protein Design, Northeastern University, Vanderbilt University Meiler Lab, UC Davis
Supported by: DARPA, NSF, NIH, HHMI, Amazon, Microsoft, Adobe, RosettaCommons