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

Memory leak detected in plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lawyn
Junior Member
Join Date: Jul 2020
Old 03-25-2021 , 07:59   Memory leak detected in plugin
Reply With Quote #1

I got this error after 10-15 minutes when server start. This error shutting down my plugin and all natives are in use by this.
Code:
L 03/25/2021 - 11:22:51: [SM] MEMORY LEAK DETECTED IN PLUGIN (file "jailbreak_shop_remake.smx")
L 03/25/2021 - 11:22:51: [SM] Unloading plugin to free 26524 handles.
L 03/25/2021 - 11:22:51: [SM] Contact the author(s) of this plugin to correct this error.
L 03/25/2021 - 11:22:51: --------------------------------------------------------------------------
L 03/25/2021 - 11:22:51: Type	IQuery              |	Count	26522
L 03/25/2021 - 11:22:51: Type	IDatabase           |	Count	1
L 03/25/2021 - 11:22:51: Type	Timer               |	Count	1
L 03/25/2021 - 11:22:51: -- Approximately 0 bytes of memory are in use by (26524) Handles.
I used functions to get all i need from a database.
PHP Code:
int GetClientCredits2(int client)
{
    
char steamid[55], qwe[256];
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "SELECT credite FROM shopp WHERE steamid='%s'"steamid);
    
Handle asd SQL_Query(DBqwe);
    if (
asd != INVALID_HANDLE && SQL_FetchRow(asd)) { return SQL_FetchInt(asd0); CloseHandle(asd);}
    
CloseHandle(asd);
}

int GetClientRP2(int client)
{
    
char steamid[55], qwe[256];
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "SELECT rp FROM shopp WHERE steamid='%s'"steamid);
    
Handle asd SQL_Query(DBqwe);
    if (
asd != INVALID_HANDLE && SQL_FetchRow(asd)) { return SQL_FetchInt(asd0); CloseHandle(asd);}
    
CloseHandle(asd);
}

int GetClientJob2(int client)
{
    
char steamid[55], qwe[256];
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "SELECT job FROM shopp WHERE steamid='%s'"steamid);
    
Handle asd SQL_Query(DBqwe);
    if (
asd != INVALID_HANDLE && SQL_FetchRow(asd)) { return SQL_FetchInt(asd0); CloseHandle(asd);}
    
CloseHandle(asd);
}

int GetClientMats2(int client)
{
    
char steamid[55], qwe[256];
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "SELECT materiale FROM shopp WHERE steamid='%s'"steamid);
    
Handle asd SQL_Query(DBqwe);
    if (
asd != INVALID_HANDLE && SQL_FetchRow(asd)) { return SQL_FetchInt(asd0); CloseHandle(asd);}
    
CloseHandle(asd);
}

int GetClientDrugs2(int client)
{
    
char steamid[55], qwe[256];
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "SELECT droguri FROM shopp WHERE steamid='%s'"steamid);
    
Handle asd SQL_Query(DBqwe);
    if (
asd != INVALID_HANDLE && SQL_FetchRow(asd)) { return SQL_FetchInt(asd0); CloseHandle(asd);}
    
CloseHandle(asd);
}

int GetClientOre2(int client)
{
    
char steamid[55], qwe[256];
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "SELECT ore FROM shopp WHERE steamid='%s'"steamid);
    
Handle asd SQL_Query(DBqwe);
    if (
asd != INVALID_HANDLE && SQL_FetchRow(asd)) { return SQL_FetchInt(asd0); CloseHandle(asd);}
    
CloseHandle(asd);
}

int GetClientMinute2(int client)
{
    
char steamid[55], qwe[256];
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "SELECT minute FROM shopp WHERE steamid='%s'"steamid);
    
Handle asd SQL_Query(DBqwe);
    if (
asd != INVALID_HANDLE && SQL_FetchRow(asd)) { return SQL_FetchInt(asd0); CloseHandle(asd);}
    
CloseHandle(asd);
}

int GetClientSecunde2(int client)
{
    
char steamid[55], qwe[256];
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "SELECT secunde FROM shopp WHERE steamid='%s'"steamid);
    
Handle asd SQL_Query(DBqwe);
    if (
asd != INVALID_HANDLE && SQL_FetchRow(asd)) { return SQL_FetchInt(asd0); CloseHandle(asd);}
    
CloseHandle(asd);
}

int GetClientOreAdmin2(int client)
{
    
char steamid[55], qwe[256];
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "SELECT oreadmin FROM shopp WHERE steamid='%s'"steamid);
    
Handle asd SQL_Query(DBqwe);
    if (
asd != INVALID_HANDLE && SQL_FetchRow(asd)) { return SQL_FetchInt(asd0); CloseHandle(asd);}
    
CloseHandle(asd);
}

int GetClientSkillMats(int client)
{
    
char steamid[55], qwe[256];
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "SELECT skillmats FROM shopp WHERE steamid='%s'"steamid);
    
Handle asd SQL_Query(DBqwe);
    if (
asd != INVALID_HANDLE && SQL_FetchRow(asd)) { return SQL_FetchInt(asd0); CloseHandle(asd);}
    
CloseHandle(asd);
}

int GetClientSkillDrugs(int client)
{
    
char steamid[55], qwe[256];
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "SELECT skilldrugs FROM shopp WHERE steamid='%s'"steamid);
    
Handle asd SQL_Query(DBqwe);
    if (
asd != INVALID_HANDLE && SQL_FetchRow(asd)) { return SQL_FetchInt(asd0); CloseHandle(asd);}
    
CloseHandle(asd);
}

int GetClientSkillAsasin(int client)
{
    
char steamid[55], qwe[256];
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "SELECT skillasasin FROM shopp WHERE steamid='%s'"steamid);
    
Handle asd SQL_Query(DBqwe);
    if (
asd != INVALID_HANDLE && SQL_FetchRow(asd)) { return SQL_FetchInt(asd0); CloseHandle(asd);}
    
CloseHandle(asd);
}

void SetClientOre2(int clientint suma)
{
    
char steamid[55], qwe[256], name[MAX_NAME_LENGTH];
    
GetClientName(clientnamesizeof(name));
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "UPDATE shopp SET nume='%s', steamid='%s', ore='%i' WHERE steamid='%s'"namesteamidsumasteamid);
    
Handle asd SQL_Query(DBqwe);
    
CloseHandle(asd);
}

void SetClientJob2(int clientint suma)
{
    
char steamid[55], qwe[256], name[MAX_NAME_LENGTH];
    
GetClientName(clientnamesizeof(name));
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "UPDATE shopp SET nume='%s', steamid='%s', job='%i' WHERE steamid='%s'"namesteamidsumasteamid);
    
Handle asd SQL_Query(DBqwe);
    
CloseHandle(asd);
}

void SetClientMinute2(int clientint suma)
{
    
char steamid[55], qwe[256], name[MAX_NAME_LENGTH];
    
GetClientName(clientnamesizeof(name));
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "UPDATE shopp SET nume='%s', steamid='%s', minute='%i' WHERE steamid='%s'"namesteamidsumasteamid);
    
Handle asd SQL_Query(DBqwe);
    
CloseHandle(asd);
}

void SetClientSecunde2(int clientint suma)
{
    
char steamid[55], qwe[256], name[MAX_NAME_LENGTH];
    
GetClientName(clientnamesizeof(name));
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "UPDATE shopp SET nume='%s', steamid='%s', secunde='%i' WHERE steamid='%s'"namesteamidsumasteamid);
    
Handle asd SQL_Query(DBqwe);
    
CloseHandle(asd);
}

void SetClientCredits2(int clientint suma)
{
    
char steamid[55], qwe[256], name[MAX_NAME_LENGTH];
    
GetClientName(clientnamesizeof(name));
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "UPDATE shopp SET nume='%s', steamid='%s', credite='%i' WHERE steamid='%s'"namesteamidGetClientCredits2(client) + sumasteamid);
    
Handle asd SQL_Query(DBqwe);
    
CloseHandle(asd);
}

void SetClientMats2(int clientint suma)
{
    
char steamid[55], qwe[256], name[MAX_NAME_LENGTH];
    
GetClientName(clientnamesizeof(name));
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "UPDATE shopp SET nume='%s', steamid='%s', materiale='%i' WHERE steamid='%s'"namesteamidGetClientMats2(client) + sumasteamid);
    
Handle asd SQL_Query(DBqwe);
    
CloseHandle(asd);
}

void SetClientDrugs2(int clientint suma)
{
    
char steamid[55], qwe[256], name[MAX_NAME_LENGTH];
    
GetClientName(clientnamesizeof(name));
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "UPDATE shopp SET nume='%s', steamid='%s', droguri='%i' WHERE steamid='%s'"namesteamidGetClientDrugs2(client) + sumasteamid);
    
Handle asd SQL_Query(DBqwe);
    
CloseHandle(asd);
}

void SetClientRP2(int clientint suma)
{
    
char steamid[55], qwe[256], name[MAX_NAME_LENGTH];
    
GetClientName(clientnamesizeof(name));
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "UPDATE shopp SET nume='%s', steamid='%s', rp='%i' WHERE steamid='%s'"namesteamidGetClientRP2(client) + sumasteamid);
    
Handle asd SQL_Query(DBqwe);
    
CloseHandle(asd);
}

void SetClientOreAdmin2(int clientint suma)
{
    
char steamid[55], qwe[256], name[MAX_NAME_LENGTH];
    
GetClientName(clientnamesizeof(name));
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "UPDATE shopp SET nume='%s', steamid='%s', oreadmin='%i' WHERE steamid='%s'"namesteamidsumasteamid);
    
Handle asd SQL_Query(DBqwe);
    
CloseHandle(asd);
}

void SetClientSkillDrugs(int clientint suma)
{
    
char steamid[55], qwe[256], name[MAX_NAME_LENGTH];
    
GetClientName(clientnamesizeof(name));
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "UPDATE shopp SET nume='%s', steamid='%s', skilldrugs='%i' WHERE steamid='%s'"namesteamidGetClientSkillDrugs(client) + sumasteamid);
    
Handle asd SQL_Query(DBqwe);
    
CloseHandle(asd);
}

void SetClientSkillMats(int clientint suma)
{
    
char steamid[55], qwe[256], name[MAX_NAME_LENGTH];
    
GetClientName(clientnamesizeof(name));
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "UPDATE shopp SET nume='%s', steamid='%s', skillmats='%i' WHERE steamid='%s'"namesteamidGetClientSkillMats(client) + sumasteamid);
    
Handle asd SQL_Query(DBqwe);
    
CloseHandle(asd);
}

void SetClientSkillAsasin(int clientint suma)
{
    
char steamid[55], qwe[256], name[MAX_NAME_LENGTH];
    
GetClientName(clientnamesizeof(name));
    
GetClientAuthString(clientsteamidsizeof(steamid));
    
Format(qwesizeof(qwe), "UPDATE shopp SET nume='%s', steamid='%s', skillasasin='%i' WHERE steamid='%s'"namesteamidGetClientSkillAsasin(client) + sumasteamid);
    
Handle asd SQL_Query(DBqwe);
    
CloseHandle(asd);

__________________
Lawyn is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-25-2021 , 09:22   Re: Memory leak detected in plugin
Reply With Quote #2

You maybe need fetch result into variable, close handle, then return variable (as result or 0, false, etc. etc.)
Quote:
Originally Posted by Lawyn View Post
Code:
...
	Handle asd = SQL_Query(DB, qwe);
	if (asd != INVALID_HANDLE && SQL_FetchRow(asd)) { return SQL_FetchInt(asd, 0); CloseHandle(asd);}
	CloseHandle(asd);
...

Last edited by Bacardi; 03-25-2021 at 09:24.
Bacardi is offline
Lawyn
Junior Member
Join Date: Jul 2020
Old 03-25-2021 , 14:49   Re: Memory leak detected in plugin
Reply With Quote #3

Quote:
Originally Posted by Bacardi View Post
You maybe need fetch result into variable, close handle, then return variable (as result or 0, false, etc. etc.)
It doesn`t work
__________________
Lawyn is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 03-25-2021 , 15:55   Re: Memory leak detected in plugin
Reply With Quote #4

Show your code
__________________
Do not Private Message @me
Bacardi is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 03-25-2021 , 17:14   Re: Memory leak detected in plugin
Reply With Quote #5

try changing the lines to:

PHP Code:
...
    
int value;
    if (
asd != INVALID_HANDLE && SQL_FetchRow(asd)) { value SQL_FetchInt(asd0); }
    
CloseHandle(asd);
    return 
value;
... 
__________________
Marttt is offline
Lawyn
Junior Member
Join Date: Jul 2020
Old 03-26-2021 , 13:19   Re: Memory leak detected in plugin
Reply With Quote #6

Quote:
Originally Posted by Bacardi View Post
Show your code
PHP Code:
int GetClientSkillDrugs(int client)
{
    
char steamid[55], qwe[256];
    
GetClientAuthId(clientAuthId_Steam2steamidsizeof(steamid));
    
Format(qwesizeof(qwe), "SELECT skilldrugs FROM shopp WHERE steamid='%s'"steamid);
    
Handle asd SQL_Query(DBqwe);
    
int suma = -1;
    if (
asd != INVALID_HANDLE && SQL_FetchRow(asd)) { suma SQL_FetchInt(asd0); }
    
CloseHandle(asd); asd INVALID_HANDLE;
    return 
suma;

This work better !
__________________
Lawyn is offline
Lawyn
Junior Member
Join Date: Jul 2020
Old 03-26-2021 , 13:19   Re: Memory leak detected in plugin
Reply With Quote #7

Quote:
Originally Posted by Marttt View Post
try changing the lines to:

PHP Code:
...
    
int value;
    if (
asd != INVALID_HANDLE && SQL_FetchRow(asd)) { value SQL_FetchInt(asd0); }
    
CloseHandle(asd);
    return 
value;
... 
Thx man, worked!
__________________
Lawyn is offline
Reply


Thread Tools
Display Modes

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 07:08.


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