Raised This Month: $51 Target: $400
 12% 

Solved DataPacks and queries leaking?


Post New Thread Reply   
 
Thread Tools Display Modes
pride95
Senior Member
Join Date: Aug 2015
Old 03-11-2018 , 07:55   Re: DataPacks and queries leaking?
Reply With Quote #11

You should check just

PHP Code:
DBResultSet results 
PHP Code:
if(results != null) {} 
pride95 is offline
brunoronning
Senior Member
Join Date: Jan 2014
Location: Brazil
Old 03-11-2018 , 16:04   Re: DataPacks and queries leaking?
Reply With Quote #12

Quote:
Originally Posted by asherkin View Post
You now have a very obvious leak on any query failure.
Sorry:
Spoiler
brunoronning is offline
sdz
Senior Member
Join Date: Feb 2012
Old 03-12-2018 , 07:57   Re: DataPacks and queries leaking?
Reply With Quote #13

Quote:
Originally Posted by brunoronning View Post
Try this method:
It is not elegant, but it works.

PHP Code:
public void SomeFunction()
{
    
DataPack pack = new DataPack();
    
pack.WriteCell(69);
    
pack.WriteCell(420);

    
char szQuery[32];
    
Format(szQuerysizeof(szQuery), "SELECT * FROM test");
    
g_dbTest.Query(SQLCallback_TestszQuerypack);
}

public 
void SQLCallback_Test(Database dbDBResultSet results, const char[] sErrorDataPack data)
{   
    
//db not connected or something went wrong with connection:
    
if (db == null)
    {
        
LogError("(SQLCallback_Test) Database not connected or failed to connect, aboring query...");
        return;
    }
    
//query fucked up:
    
else if(results == null)
    {
        
LogError("(SQLCallback_Test) Fail at Query: %s"sError);
    }

    
int iValue1;
    
int iValue2;

    
data.Reset();
    
iValue1 data.ReadCell();
    
iValue2 data.ReadCell();
    
delete data;

    
// Your Code.

sdz is offline
xm3kilo
Member
Join Date: Jan 2018
Old 03-13-2018 , 14:44   Re: DataPacks and queries leaking?
Reply With Quote #14

Thanks for all the help guys I'll try the above method
xm3kilo is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 03-13-2018 , 15:31   Re: DataPacks and queries leaking?
Reply With Quote #15

Quote:
Originally Posted by EasSidezz View Post
-snip-
Quote:
Originally Posted by asherkin View Post
You now have a very obvious leak on any query failure.
headline is offline
OSWO
Senior Member
Join Date: Jul 2015
Location: United Kingdom, London
Old 03-15-2018 , 14:51   Re: DataPacks and queries leaking?
Reply With Quote #16

I don't think it's helpful quoting someones previous statement, and rather showing the actual problem.

When it fails you return; without disposing the DataPack handle.
__________________
SourceTimer | WeaponSkins++ | BasePlugins++ https://github.com/OSCAR-WOS
OSWO is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 03-15-2018 , 14:55   Re: DataPacks and queries leaking?
Reply With Quote #17

Quote:
Originally Posted by OSWO View Post
I don't think it's helpful quoting someones previous statement, and rather showing the actual problem.
Thankfully, it was the same problem that asherkin pointed out, so I didn't need to. I don't know how it could be any more clear.
Quote:
Originally Posted by asherkin View Post
on any query failure

Last edited by headline; 03-15-2018 at 14:56.
headline is offline
OSWO
Senior Member
Join Date: Jul 2015
Location: United Kingdom, London
Old 03-15-2018 , 15:53   Re: DataPacks and queries leaking?
Reply With Quote #18

Still on that high horse I see
__________________
SourceTimer | WeaponSkins++ | BasePlugins++ https://github.com/OSCAR-WOS
OSWO is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 03-15-2018 , 22:30   Re: DataPacks and queries leaking?
Reply With Quote #19

Quote:
Originally Posted by OSWO View Post
Still on that high horse I see
It's understandable why Headline did it, an issue with leaking DataPack handles was never addressed even though it was obvious AND pointed out, so it's understandable that Headline would be angry at the disregard (I would too)
__________________
WildCard65 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:39.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode