Raised This Month: $ Target: $400
 0% 

SQLx threads memory leak problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kim_perm
Member
Join Date: Sep 2007
Location: Perm, Russia
Old 05-21-2009 , 01:41   SQLx threads memory leak problem
Reply With Quote #1

Hello!
I have a problem with SQLx module (tested on v1.76b and v1.8.1.3, linux and windows)

I write plugin where I execute many querys. And I have a problem with "memory leak". In fact, I have a gigabyte memory usage for single server (after some time). I made a dump for analysis and saw that it stores all the requests maded by my plugin (found strings like "SELECT ....").
Question: What's my mistake?

PS: sory for my english.
PPS: For example, cite the text of the test plugin:

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <sqlx> #define PLUGIN "test_sqlx_threaded" #define VERSION "0.0.1" #define AUTHOR "kim" #define QUERY_ID 1 #define TASK_CHECK_PLAYERS_ID 1001 static Handle:g_db_tuple static g_QueryNum public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR); } public plugin_cfg() {     set_task(2.0, "task_plugin_cfg"); } public plugin_end() {     if(g_db_tuple != Empty_Handle) SQL_FreeHandle(g_db_tuple); } public task_plugin_cfg() {     g_db_tuple = SQL_MakeStdTuple(5);     set_task(1.0, "task_check_players", TASK_CHECK_PLAYERS_ID, _, _, "b"); } public task_check_players() {     static query_string[256], query_data[2]     format(query_string, 255, "SELECT `player_auth` FROM `players_stat` WHERE `server_name` = '%s'", "cs01");     query_data[0] = g_QueryNum++;     query_data[1] = QUERY_ID;     SQL_ThreadQuery(g_db_tuple, "handle_query", query_string, query_data, 2); } public handle_query(failstate, Handle:query, error[], errnum, query_data[], size, Float:queuetime) { //    new query_string[512] //    SQL_GetQueryString(query, query_string, 511); //    log_amx("handle query: %s", query_string);     //server_print("debug info: handle_query (%d). start.", query_data[1]);     if (failstate) {         if (failstate == TQUERY_CONNECT_FAILED) {             log_amx(" --> Connection failed!")         } else if (failstate == TQUERY_QUERY_FAILED) {             log_amx(" --> Query failed!")         }         log_amx(" --> Error code: %d (Message: ^"%s^")", errnum, error)         new query_string[512]         SQL_GetQueryString(query, query_string, 511);         log_amx(" --> Original query: ^"%s^")", query_string);     } else {         switch (query_data[1]) {             case QUERY_ID:                 if(SQL_MoreResults(query)) {                                         //server_print("debug info: handle_query (%d). more result.", query_data[1]);                                         static qcolAuth                     qcolAuth = SQL_FieldNameToNum(query, "player_auth");                                         static player_auth[41]                     while (SQL_MoreResults(query)) {                         SQL_ReadResult(query, qcolAuth, player_auth, 40);                         SQL_NextRow(query);                     }                 }             }         }         // ??? SQL_FreeHandle(query);     //server_print("debug info: handle_query (%d). end.", query_data[1]);     // ??? return PLUGIN_CONTINUE } /* CREATE TABLE IF NOT EXISTS `players_stat` (`server_name` VARCHAR(10), `player_auth` VARCHAR(40)) */

Last edited by kim_perm; 05-21-2009 at 01:47.
kim_perm is offline
kim_perm
Member
Join Date: Sep 2007
Location: Perm, Russia
Old 05-22-2009 , 01:58   Re: SQLx threads memory leak problem
Reply With Quote #2

No one?
May be wrong forum thread...
kim_perm is offline
Shinkoru
New Member
Join Date: Aug 2008
Old 05-22-2009 , 12:42   Re: SQLx threads memory leak problem
Reply With Quote #3

I'm no expert at SQLx but it seems you're not freeing the handle/query, which causes it to leak if I remember correctly. I believe you free the query using the same function you use to close the connection.
Code:
SQL_FreeHandle(Query)
Shinkoru is offline
kim_perm
Member
Join Date: Sep 2007
Location: Perm, Russia
Old 05-22-2009 , 13:14   Re: SQLx threads memory leak problem
Reply With Quote #4

Quote:
Originally Posted by Shinkoru View Post
I'm no expert at SQLx but it seems you're not freeing the handle/query, which causes it to leak if I remember correctly. I believe you free the query using the same function you use to close the connection.
Code:
SQL_FreeHandle(Query)
I try to free handle, this not work

and in funkwiki and in sqlx.inc:
Quote:
* @param query - Handle to the query, do not free it.
kim_perm is offline
BAILOPAN
Join Date: Jan 2004
Old 05-24-2009 , 13:41   Re: SQLx threads memory leak problem
Reply With Quote #5

Does changing the map alleviate memory problems?

Anyway, if there is a memory leak, please post a bug report. Attach dumps or e-mail to [email protected] if too big (or contains private data).
__________________
egg
BAILOPAN is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 05-24-2009 , 13:45   Re: SQLx threads memory leak problem
Reply With Quote #6

Shoop ma whoop. bailopan in amxx scripting help
__________________
xPaw 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 01:24.


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