Issue
I have enjoyed success utilizing the MySQL/Connector C libraries within my C application to manipulate a database. Use of the application, however, causes great memory usage, so much in fact that I have had to consider utilizing systemd
to manage the application, which I assume will run at startup as a service since it needs to always be active. Rather than obfuscate/add complexity to this any further, I'd like to address the issue within the application.
- System: Raspberry Pi 4B
- OS: Raspbian Buster
- SQL Library: mariadb-connector-c-3.1.7
- Database: MariaDB 10.3.22 server, locally hosted
I typically clear queries that store result sets to my MYSQL_RES object using mysql_free_result(sqlRes)
. Inserts I keep fairly simple. Everything works correctly from a functional standpoint, but it's memory consumption is just through the roof. I am assuming a lot of this is due to my wait times in the main() looping code, but I want to be able to monitor a UART connection in nonblocking fashion with a host system that communicates at 115.2k.
Is there a best practice I am veering way off course from? A lot of my initial code was developed similar to that outlined here. I have not utilized any memory analysis applications within Raspbian as I am not too familiar with them.
Thanks
// 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, '\0', 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);
}
EDIT 1: Valgrind log insanity
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==
Solution
mysql_free_result
needs to occur for (sqlRes) && !(numRows)
Answered By - danblack