使用 MySQL/Connector C 库的 C 应用程序消耗内存非常快
C application using MySQL/Connector C libraries consuming memory very fast
我很高兴在我的 C 应用程序中使用 MySQL/Connector C 库来操作数据库。但是,使用该应用程序会导致大量内存使用,事实上我不得不考虑使用 systemd
来管理该应用程序,我认为它会 运行 在启动时作为一项服务,因为它需要始终保持活跃。我想在应用程序中解决这个问题,而不是 obfuscate/add 进一步复杂化。
- 系统:Raspberry Pi4B
- OS: Raspbian克星
- SQL 库:mariadb-connector-c-3.1.7
- 数据库:MariaDB 10.3.22 服务器,本地
托管
我通常使用 mysql_free_result(sqlRes)
清除将结果集存储到我的 MYSQL_RES 对象的查询。插入我保持相当简单。从功能的角度来看,一切正常,但它的内存消耗只是通过屋顶。我假设这在很大程度上是由于我在 main() 循环代码中的等待时间,但我希望能够以非阻塞方式监视与以 115.2k 通信的主机系统的 UART 连接。
是否有我正在偏离的最佳实践?我的许多初始代码的开发类似于概述 here。我没有在 Raspbian 中使用任何内存分析应用程序,因为我不太熟悉它们。
谢谢
// MySQL/Connector C API objects for database management
MYSQL *connect; // MySQL object for managing connection
MYSQL_RES *sqlRes; // When querying a results set, use this object to store them
MYSQL_ROW sqlRow; // When iterating through results, use this object to store each
MYSQL_FIELD *sqlFields;
int mysql_query_status=0;
my_ulonglong numRows;
unsigned int numFields;
int insert_t_data(char* id, char* level, char* di)
{
// Insert data records into database
int strret = snprintf(insertString, 103, "INSERT INTO t_data (id, value_type, value) VALUES ('%s', '%s', '%s');", id, di, level);
mysql_query_status = mysql_query(connect, insertString);
if (mysql_query_status)
{
printf("MySQL error at Insert into t_data: %s",mysql_error(connect));
errchk++;
return 1;
}
return 0;
}
int update_tank(char* id, uint8_t sh, uint8_t sl, uint8_t ts, uint8_t alarms_anc)
{
uint8_t hf = (alarms_anc >> 1) & 1U;
// Insert t_data records into database
int strret = snprintf(insertString, 100, "SELECT * FROM t WHERE description='%s' ORDER BY timestamp DESC LIMIT 1;", id);
if ((mysql_query_status=mysql_query(connect, insertString))) // Error in query
{
printf("Couldn't find existing record. Inserting new record to 't' for '%s'",id);
}
else // Successful query (but not necessarily any rows)
{
sqlRes = mysql_store_result(connect); // Retrieve the resulting set from this query
numRows = mysql_num_rows(sqlRes);
if ((sqlRes) && (numRows))
{
// Record already exists, proceed to update.
mysql_free_result(sqlRes);
}
else
{
// Create a row since it wasn't there, proceed to update.
strret = snprintf(insertString, 75, "INSERT INTO t (r_id, description) VALUES ('%d', '%s');", 4digit, id);
mysql_query_status = mysql_query(connect, insertString);
if (mysql_query_status)
{
printf("MySQL error at t: %s",mysql_error(connect));
errchk++;
}
}
}
strret = snprintf(insertString, 150, "UPDATE t SET high='%d', low='%d', height='%d', h='%d' WHERE description='%s'", sh, sl, ts, hf, id);
mysql_query_status = mysql_query(connect, insertString);
if (mysql_query_status)
{
printf("MySQL error at t_data: %s",mysql_error(connect));
errchk++;
return 1;
}
return 0;
}
void db_connect(void)
{
printf("Reached DB Connect.\n");
connect = mysql_init(NULL);
connect = mysql_real_connect(connect,SERVER,USER,PASSWORD,DATABASE,0,NULL,0);
if ((!connect) || (connect == NULL))
{
printf("MySQL failed to initialize. Connection to 'db' failed.\n");
errchk=1; // Use errchk throughout for reconnect
}
else
{
printf("Connection successful.\n");
}
}
int main(void)
{
usleep(5000); // Slight delay at startup
memset(&rbuf, '[=11=]', sizeof(rbuf)); // Clear read buffer before communication
bufptr=rbuf;
db_connect();
// LOOP section ---------------
while(TRUE)
{
// 1.) Read serial port for real-time updates
// 2.) Write SQL data resulting from any updates
// 3.) Read SQL tables for any user actions/updates
// 4.) Write serial actions/cmds
if (errchk > 10) {
mysql_close(connect);
sleep(10);
errchk=0;
db_connect();
}
usleep(100000); // Wait 100ms - This setting consumes 0.1% memory every 50 sec
// usleep(10000); // Wait 10 ms - Ideal - This setting consumes 0.1% memory every 10 sec
check_uart(); // This is a function that can trigger SQL inserts/updates
// if new data detected, then...
insert_t_data(id,level,di);
// if new updates needed, then...
update_tank(id, sh, sl, size, alarms);
}
close(serial_port);
mysql_close(connect);
}
编辑 1:Valgrind 日志异常
pi@raspberrypi:~/beehive/bin/Debug $ valgrind --leak-check=yes ./beehive
==6693== Memcheck, a memory error detector
==6693== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==6693== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==6693== Command: ./beehive
==6693==
--6693-- WARNING: Serious error when reading debug info
--6693-- When reading debug info from /lib/arm-linux-gnueabihf/ld-2.28.so:
--6693-- Ignoring non-Dwarf2/3/4 block in .debug_info
--6693-- WARNING: Serious error when reading debug info
--6693-- When reading debug info from /lib/arm-linux-gnueabihf/ld-2.28.so:
--6693-- Last block truncated in .debug_info; ignoring
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401A5D0: index (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401A5D4: index (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4008040: _dl_dst_count (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4008288: expand_dynamic_string_token (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401AA80: strlen (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401AA84: strlen (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4017F68: malloc (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4017F74: malloc (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B5E8: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B608: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B618: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B634: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B63C: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B664: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B664: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B68C: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B6A0: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B6A4: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B6B0: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x40180A4: calloc (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4017FA8: malloc (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401A160: mmap (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Syscall param mmap2(start) contains uninitialised byte(s)
==6693== at 0x401A174: mmap (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Syscall param mmap2(length) contains uninitialised byte(s)
==6693== at 0x401A174: mmap (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Syscall param mmap2(offset) contains uninitialised byte(s)
==6693== at 0x401A174: mmap (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4017F44: malloc (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x400BDD0: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B5F4: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B630: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BD7C: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BD98: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401AA14: strdup (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B660: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B660: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B688: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4008E20: _dl_map_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Syscall param openat(filename) contains uninitialised byte(s)
==6693== at 0x4019F4C: __open64_nocancel (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x40180E4: free (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x400BB84: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BB9C: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BBBC: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BBC0: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BBE0: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BC50: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BC64: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BCA8: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BCC0: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401AA30: strlen (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401AA48: strlen (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B628: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BD9C: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4005D98: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4005DC4: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4005DD0: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4005E50: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4005E9C: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4005EA0: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400602C: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x40060C0: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x40060DC: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4006114: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4006A0C: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x40061D4: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4010FF4: _dl_name_match_p (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4011008: _dl_name_match_p (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401A620: strcmp (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4010FFC: _dl_name_match_p (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4013660: _dl_get_origin (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B680: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B684: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B690: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B694: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B6B0: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B6B4: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4013674: _dl_get_origin (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x400832C: expand_dynamic_string_token (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x40082E4: expand_dynamic_string_token (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4008114: _dl_dst_substitute (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401A67C: strcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4008198: _dl_dst_substitute (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B6A8: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B6AC: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B6B4: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x400926C: _dl_map_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B7A0: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B6AC: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B658: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B65C: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B668: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B66C: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B658: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B850: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B6A0: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B6A4: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B6A8: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4005FE0: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4006020: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B648: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B900: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
--6693-- WARNING: Serious error when reading debug info
--6693-- When reading debug info from /lib/arm-linux-gnueabihf/libm-2.28.so:
--6693-- Ignoring non-Dwarf2/3/4 block in .debug_info
--6693-- WARNING: Serious error when reading debug info
--6693-- When reading debug info from /lib/arm-linux-gnueabihf/libm-2.28.so:
--6693-- Last block truncated in .debug_info; ignoring
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B66C: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693==
==6693== More than 100 errors detected. Subsequent errors
==6693== will still be recorded, but in less detail than before.
==6693== Use of uninitialised value of size 4
==6693== at 0x4005FCC: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
--6693-- WARNING: Serious error when reading debug info
--6693-- When reading debug info from /lib/arm-linux-gnueabihf/libc-2.28.so:
--6693-- Ignoring non-Dwarf2/3/4 block in .debug_info
--6693-- WARNING: Serious error when reading debug info
--6693-- When reading debug info from /lib/arm-linux-gnueabihf/libc-2.28.so:
--6693-- Last block truncated in .debug_info; ignoring
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x400E3FC: _dl_map_object_deps (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400E410: _dl_map_object_deps (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B668: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
mysql_free_result
需要发生 (sqlRes) && !(numRows)
我很高兴在我的 C 应用程序中使用 MySQL/Connector C 库来操作数据库。但是,使用该应用程序会导致大量内存使用,事实上我不得不考虑使用 systemd
来管理该应用程序,我认为它会 运行 在启动时作为一项服务,因为它需要始终保持活跃。我想在应用程序中解决这个问题,而不是 obfuscate/add 进一步复杂化。
- 系统:Raspberry Pi4B
- OS: Raspbian克星
- SQL 库:mariadb-connector-c-3.1.7
- 数据库:MariaDB 10.3.22 服务器,本地 托管
我通常使用 mysql_free_result(sqlRes)
清除将结果集存储到我的 MYSQL_RES 对象的查询。插入我保持相当简单。从功能的角度来看,一切正常,但它的内存消耗只是通过屋顶。我假设这在很大程度上是由于我在 main() 循环代码中的等待时间,但我希望能够以非阻塞方式监视与以 115.2k 通信的主机系统的 UART 连接。
是否有我正在偏离的最佳实践?我的许多初始代码的开发类似于概述 here。我没有在 Raspbian 中使用任何内存分析应用程序,因为我不太熟悉它们。
谢谢
// MySQL/Connector C API objects for database management
MYSQL *connect; // MySQL object for managing connection
MYSQL_RES *sqlRes; // When querying a results set, use this object to store them
MYSQL_ROW sqlRow; // When iterating through results, use this object to store each
MYSQL_FIELD *sqlFields;
int mysql_query_status=0;
my_ulonglong numRows;
unsigned int numFields;
int insert_t_data(char* id, char* level, char* di)
{
// Insert data records into database
int strret = snprintf(insertString, 103, "INSERT INTO t_data (id, value_type, value) VALUES ('%s', '%s', '%s');", id, di, level);
mysql_query_status = mysql_query(connect, insertString);
if (mysql_query_status)
{
printf("MySQL error at Insert into t_data: %s",mysql_error(connect));
errchk++;
return 1;
}
return 0;
}
int update_tank(char* id, uint8_t sh, uint8_t sl, uint8_t ts, uint8_t alarms_anc)
{
uint8_t hf = (alarms_anc >> 1) & 1U;
// Insert t_data records into database
int strret = snprintf(insertString, 100, "SELECT * FROM t WHERE description='%s' ORDER BY timestamp DESC LIMIT 1;", id);
if ((mysql_query_status=mysql_query(connect, insertString))) // Error in query
{
printf("Couldn't find existing record. Inserting new record to 't' for '%s'",id);
}
else // Successful query (but not necessarily any rows)
{
sqlRes = mysql_store_result(connect); // Retrieve the resulting set from this query
numRows = mysql_num_rows(sqlRes);
if ((sqlRes) && (numRows))
{
// Record already exists, proceed to update.
mysql_free_result(sqlRes);
}
else
{
// Create a row since it wasn't there, proceed to update.
strret = snprintf(insertString, 75, "INSERT INTO t (r_id, description) VALUES ('%d', '%s');", 4digit, id);
mysql_query_status = mysql_query(connect, insertString);
if (mysql_query_status)
{
printf("MySQL error at t: %s",mysql_error(connect));
errchk++;
}
}
}
strret = snprintf(insertString, 150, "UPDATE t SET high='%d', low='%d', height='%d', h='%d' WHERE description='%s'", sh, sl, ts, hf, id);
mysql_query_status = mysql_query(connect, insertString);
if (mysql_query_status)
{
printf("MySQL error at t_data: %s",mysql_error(connect));
errchk++;
return 1;
}
return 0;
}
void db_connect(void)
{
printf("Reached DB Connect.\n");
connect = mysql_init(NULL);
connect = mysql_real_connect(connect,SERVER,USER,PASSWORD,DATABASE,0,NULL,0);
if ((!connect) || (connect == NULL))
{
printf("MySQL failed to initialize. Connection to 'db' failed.\n");
errchk=1; // Use errchk throughout for reconnect
}
else
{
printf("Connection successful.\n");
}
}
int main(void)
{
usleep(5000); // Slight delay at startup
memset(&rbuf, '[=11=]', sizeof(rbuf)); // Clear read buffer before communication
bufptr=rbuf;
db_connect();
// LOOP section ---------------
while(TRUE)
{
// 1.) Read serial port for real-time updates
// 2.) Write SQL data resulting from any updates
// 3.) Read SQL tables for any user actions/updates
// 4.) Write serial actions/cmds
if (errchk > 10) {
mysql_close(connect);
sleep(10);
errchk=0;
db_connect();
}
usleep(100000); // Wait 100ms - This setting consumes 0.1% memory every 50 sec
// usleep(10000); // Wait 10 ms - Ideal - This setting consumes 0.1% memory every 10 sec
check_uart(); // This is a function that can trigger SQL inserts/updates
// if new data detected, then...
insert_t_data(id,level,di);
// if new updates needed, then...
update_tank(id, sh, sl, size, alarms);
}
close(serial_port);
mysql_close(connect);
}
编辑 1:Valgrind 日志异常
pi@raspberrypi:~/beehive/bin/Debug $ valgrind --leak-check=yes ./beehive
==6693== Memcheck, a memory error detector
==6693== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==6693== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==6693== Command: ./beehive
==6693==
--6693-- WARNING: Serious error when reading debug info
--6693-- When reading debug info from /lib/arm-linux-gnueabihf/ld-2.28.so:
--6693-- Ignoring non-Dwarf2/3/4 block in .debug_info
--6693-- WARNING: Serious error when reading debug info
--6693-- When reading debug info from /lib/arm-linux-gnueabihf/ld-2.28.so:
--6693-- Last block truncated in .debug_info; ignoring
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401A5D0: index (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401A5D4: index (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4008040: _dl_dst_count (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4008288: expand_dynamic_string_token (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401AA80: strlen (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401AA84: strlen (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4017F68: malloc (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4017F74: malloc (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B5E8: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B608: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B618: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B634: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B63C: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B664: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B664: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B68C: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B6A0: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B6A4: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B6B0: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x40180A4: calloc (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4017FA8: malloc (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401A160: mmap (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Syscall param mmap2(start) contains uninitialised byte(s)
==6693== at 0x401A174: mmap (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Syscall param mmap2(length) contains uninitialised byte(s)
==6693== at 0x401A174: mmap (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Syscall param mmap2(offset) contains uninitialised byte(s)
==6693== at 0x401A174: mmap (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4017F44: malloc (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x400BDD0: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B5F4: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B630: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BD7C: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BD98: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401AA14: strdup (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B660: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B660: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B688: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4008E20: _dl_map_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Syscall param openat(filename) contains uninitialised byte(s)
==6693== at 0x4019F4C: __open64_nocancel (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x40180E4: free (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x400BB84: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BB9C: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BBBC: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BBC0: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BBE0: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BC50: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BC64: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BCA8: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BCC0: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401AA30: strlen (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401AA48: strlen (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B628: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400BD9C: _dl_new_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4005D98: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4005DC4: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4005DD0: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4005E50: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4005E9C: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4005EA0: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400602C: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x40060C0: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x40060DC: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4006114: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4006A0C: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x40061D4: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4010FF4: _dl_name_match_p (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4011008: _dl_name_match_p (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401A620: strcmp (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4010FFC: _dl_name_match_p (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x4013660: _dl_get_origin (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B680: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B684: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B690: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B694: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B6B0: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B6B4: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4013674: _dl_get_origin (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x400832C: expand_dynamic_string_token (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x40082E4: expand_dynamic_string_token (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4008114: _dl_dst_substitute (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401A67C: strcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4008198: _dl_dst_substitute (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B6A8: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B6AC: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B6B4: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x400926C: _dl_map_object (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B7A0: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B6AC: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B658: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B65C: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B668: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B66C: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B658: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B850: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B6A0: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B6A4: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B6A8: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4005FE0: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x4006020: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B648: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x401B900: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
--6693-- WARNING: Serious error when reading debug info
--6693-- When reading debug info from /lib/arm-linux-gnueabihf/libm-2.28.so:
--6693-- Ignoring non-Dwarf2/3/4 block in .debug_info
--6693-- WARNING: Serious error when reading debug info
--6693-- When reading debug info from /lib/arm-linux-gnueabihf/libm-2.28.so:
--6693-- Last block truncated in .debug_info; ignoring
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B66C: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693==
==6693== More than 100 errors detected. Subsequent errors
==6693== will still be recorded, but in less detail than before.
==6693== Use of uninitialised value of size 4
==6693== at 0x4005FCC: _dl_map_object_from_fd (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
--6693-- WARNING: Serious error when reading debug info
--6693-- When reading debug info from /lib/arm-linux-gnueabihf/libc-2.28.so:
--6693-- Ignoring non-Dwarf2/3/4 block in .debug_info
--6693-- WARNING: Serious error when reading debug info
--6693-- When reading debug info from /lib/arm-linux-gnueabihf/libc-2.28.so:
--6693-- Last block truncated in .debug_info; ignoring
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x400E3FC: _dl_map_object_deps (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Use of uninitialised value of size 4
==6693== at 0x400E410: _dl_map_object_deps (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
==6693== Conditional jump or move depends on uninitialised value(s)
==6693== at 0x401B668: memcpy (in /lib/arm-linux-gnueabihf/ld-2.28.so)
==6693==
mysql_free_result
需要发生 (sqlRes) && !(numRows)