AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   SQLx threads memory leak problem (https://forums.alliedmods.net/showthread.php?t=92851)

kim_perm 05-21-2009 01:41

SQLx threads memory leak problem
 
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)) */

kim_perm 05-22-2009 01:58

Re: SQLx threads memory leak problem
 
No one? :)
May be wrong forum thread...

Shinkoru 05-22-2009 12:42

Re: SQLx threads memory leak problem
 
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)

kim_perm 05-22-2009 13:14

Re: SQLx threads memory leak problem
 
Quote:

Originally Posted by Shinkoru (Post 832486)
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.

BAILOPAN 05-24-2009 13:41

Re: SQLx threads memory leak problem
 
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).

xPaw 05-24-2009 13:45

Re: SQLx threads memory leak problem
 
Shoop ma whoop. :o bailopan in amxx scripting help


All times are GMT -4. The time now is 01:24.

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