Hi, I sent the message below to [EMAIL PROTECTED] about one month ago but it seems that the patch didn't find it's way to the CVS and thus not in 1.0rc4 either. This fixed the memory leaks for me. The patch is for MySQL but it seems that there is a similar error in dbpgsql.c too. Maybe someone with a PostgreSQL installation could check that?
---------------------------------------------------------------------- Dbmail-imapd was leaking memory quite heavily when reading mailboxes. I am using MySQL and my dbmail installation is from the cvs. The problem was that the result from mysql database was never freed in function db_get_rfcsize() in dbmysql.c. While I was at it, I went through the file and found several less common cases with the same problem (mainly forgetting to free the result when returning an error). I hope I found all of them but cannot guarantee it. :) Here's a patch against the latest cvs version of dbmysql.c (1.52). Keep up the good work, AJT -- Arto Teräs --- See http://www.iki.fi/ajt/ for contact info
--- dbmysql.c Tue Jul 16 13:13:22 2002 +++ dbmysql.fixed Thu Aug 22 19:14:47 2002 @@ -885,6 +885,7 @@ if (!list_nodeadd(aliases, row[0], strlen(row[0])+1)) { list_freelist(&aliases->start); + mysql_free_result(res); return -2; } } @@ -1631,6 +1632,7 @@ if (mysql_num_rows(res) != 1) { trace(TRACE_WARNING, "db_icheck_messageblks(): empty messageblk table"); + mysql_free_result(res); return 0; /* nothing in table ? */ } @@ -1664,6 +1666,7 @@ if (!currids) { trace(TRACE_ERROR,"db_icheck_messageblks(): out of memory when allocatin %d items\n",ncurr); + mysql_free_result(res); return -2; } @@ -1711,6 +1714,7 @@ list_freelist(&lostlist->start); my_free(currids); currids = NULL; + mysql_free_result(res); return -2; } } @@ -1760,6 +1764,7 @@ if (mysql_num_rows(res) != 1) { trace(TRACE_WARNING, "db_icheck_messages(): empty message table"); + mysql_free_result(res); return 0; /* nothing in table ? */ } @@ -1793,6 +1798,7 @@ if (!currids) { trace(TRACE_ERROR,"db_icheck_messages(): out of memory when allocatin %d items\n",ncurr); + mysql_free_result(res); return -2; } @@ -1840,6 +1846,7 @@ list_freelist(&lostlist->start); my_free(currids); currids = NULL; + mysql_free_result(res); return -2; } } @@ -1889,6 +1896,7 @@ if (mysql_num_rows(res) != 1) { trace(TRACE_WARNING, "db_icheck_mailboxes(): empty mailbox table"); + mysql_free_result(res); return 0; /* nothing in table ? */ } @@ -1922,6 +1930,7 @@ if (!currids) { trace(TRACE_ERROR,"db_icheck_mailboxes(): out of memory when allocatin %d items\n",ncurr); + mysql_free_result(res); return -2; } @@ -1969,6 +1978,7 @@ list_freelist(&lostlist->start); my_free(currids); currids = NULL; + mysql_free_result(res); return -2; } } @@ -2401,6 +2411,7 @@ { /* none exist, none matched */ *nchildren = 0; + mysql_free_result(res); return 0; } @@ -2409,6 +2420,7 @@ if (!tmp) { trace(TRACE_ERROR,"db_findmailbox_by_regex(): not enough memory\n"); + mysql_free_result(res); return (-1); } @@ -2495,6 +2507,7 @@ if (!row) { trace(TRACE_ERROR,"db_getmailbox(): invalid mailbox id specified\n"); + mysql_free_result(res); return -1; } @@ -2684,6 +2697,7 @@ if (*nchildren == 0) { *children = NULL; + mysql_free_result(res); return 0; } *children = (u64_t*)my_malloc(sizeof(u64_t) * (*nchildren)); @@ -3698,6 +3712,7 @@ if (mysql_num_rows(res) < 1) { trace(TRACE_ERROR, "db_get_rfcsize(): message not found\n"); + mysql_free_result(res); return -1; } @@ -3707,6 +3722,7 @@ else size = 0; + mysql_free_result(res); return size; } @@ -3751,6 +3767,7 @@ if ((nrows = mysql_num_rows(res)) == 0) { + mysql_free_result(res); return 0; }