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 ....").
PS: sory for my english.
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))
*/