alongubkin / store

Store plugin for SourceMod
http://forums.alliedmods.net/showthread.php?t=207157
GNU General Public License v3.0
24 stars 45 forks source link

Fix and point out several handle leaks #18

Open peace-maker opened 9 years ago

peace-maker commented 9 years ago

The store-backend was unloaded due to lots of open handles. L 12/26/2014 - 18:46:06: [SM] MEMORY LEAK DETECTED IN PLUGIN (file "store\store-backend.smx") L 12/26/2014 - 18:46:06: [SM] Unloading plugin to free 14756 handles. L 12/26/2014 - 18:46:06: [SM] Contact the author(s) of this plugin to correct this error. L 12/26/2014 - 18:46:06: -------------------------------------------------------------------------- L 12/26/2014 - 18:46:06: TypeIDatabase |Count7413 L 12/26/2014 - 18:46:06: TypeDataPack |Count7340 L 12/26/2014 - 18:46:06: TypeGlobalFwd |Count3 L 12/26/2014 - 18:46:06: -- Approximately 96 bytes of memory are in use by (14756) Handles.

I doubt the fixes in this PR really avoid all the leaks. I've pointed out several places in the code which still leak handles but require changes to the API. The backend callbacks should really be called when the query failed too. With some "success" boolean set to false or 0 data being returned.

All the plugins that use the backend and pass a handle through the any:data callback leak that handle if the query of the method in question fails.

All the open IDatabase handles are threaded queries. A possible cause could be the database connection going away and the plugin firing far too many queries. The DBI system can't process them fast enough, so they stack up. Maybe add some more caching or use the cache more often?