[Date Prev][Date Next] [Chronological] [Thread] [Top]

memory leak when processing lots of non-trivial search queries



Hi,

we are currently testing OpenLDAP 2.0.11 under somewhat heavy
load sending lots of search requests from clients. 
Each search expr contains multiple terms and operators
(typically 3 to 5). We also use multiple additional
indexes (5-10) on the database, through the ldbm backend.

It turns out that there seems to be a memory leak in slapd.
Given my limited knowledge and understanding of the actual 
slapd code I have tried to track this down with mpatrol,
which indicates two leak areas, several similar major ones 
in filterindex.c and a smaller one in filter.c.

Enclosed are patches to ./servers/slapd/filter.c and 
./servers/slapd/back-ldbm/filterindex.c that seem to fix the
problem. While slapd would fill 1GB of main memory within a 
few minutes before, it is now stable at a minor fraction of memory.

Is there a chance to get this confirmed?

BTW, thanks for all the excellent work. Particular 2.x has been
a real step forward for us.

Thomas


# start of patch

install/openldap-2.0.11> diff -C 2 ./servers/slapd/filter.c{-2.0.11-dist,}
*** ./servers/slapd/filter.c-2.0.11-dist        Wed Oct 11 04:43:58 2000
--- ./servers/slapd/filter.c    Tue Jun 19 11:07:09 2001
***************
*** 562,565 ****
--- 562,568 ----
                        ber_bvfree( f->f_sub_final );
                }
+               if (f->f_sub != NULL) {
+                 ch_free(f->f_sub);
+               }
                break;

install/openldap-2.0.11> diff -C 2 ./servers/slapd/back-ldbm/filterindex.c{-2.0.11-dist,}
*** ./servers/slapd/back-ldbm/filterindex.c-2.0.11-dist Tue Oct  3 22:24:27 2000
--- ./servers/slapd/back-ldbm/filterindex.c     Tue Jun 19 11:06:59 2001
***************
*** 273,276 ****
--- 273,279 ----
                        idl_free( idl );
                        idl = NULL;
+                       if ( tmp != NULL ) {
+                         idl_free( tmp );
+                       }
                        Debug( LDAP_DEBUG_TRACE,
                                "<= equality_candidates key read failed (%d)\n",
***************
*** 404,407 ****
--- 407,413 ----
                        idl_free( idl );
                        idl = NULL;
+                       if ( tmp != NULL ) {
+                         idl_free( tmp );
+                       }
                        Debug( LDAP_DEBUG_TRACE, "<= approx_candidates key read failed (%d)\n",
                            rc, 0, 0 );
***************
*** 420,423 ****
--- 426,430 ----
                idl = idl_intersection( be, idl, tmp );
                idl_free( save );
+               idl_free( tmp );
 
                if( idl == NULL ) break;
***************
*** 568,571 ****
--- 575,581 ----
                        idl_free( idl );
                        idl = NULL;
+                       if ( tmp != NULL ) {
+                         idl_free( tmp );
+                       }
                        Debug( LDAP_DEBUG_TRACE, "<= substrings_candidates key read failed (%d)\n",
                            rc, 0, 0 );
***************
*** 584,587 ****
--- 594,598 ----
                idl = idl_intersection( be, idl, tmp );
                idl_free( save );
+               idl_free( tmp );
 
                if( idl == NULL ) break; 

# end of patch