[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
(ITS#4960) the memory increase quickly and not can be released sometime.
Full_Name: wang fei
Version: OpenLDAP 2.3.21
OS: slackware
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (220.167.25.214)
descirption:
i use the following code to get the info of the entry whose DN matches
"search dn".
the problem: when i call this function many times(eg: more then 1000
times), the result will be correct, but for about one or two times, after i
call ldap_search_ext_s(). the memory will increase dramitically (usually 128K, i
use system("ps aux | grep /myprogram") to find the memory it is used). and when
i ldap_msgfree(res). it only 4K memory is released.
but the other 998 times does not has this problem(the memory will not
increase). All these nodes have similar attribute except dn and cn.
when i disable the code of the inner for loop. this problem appear less
frequently.
when i disable the code which get the attribute value of entry, in other
word, both the for loop. this problem seems disappeared, but it maybe it will
appear again if it is runed more times.
// portion code of the program
static int
search_node_bydn(char *search_dn)
{
int ret;
char *a = NULL, *attrs[10], *dn;
char filter[1024];
LDAPMessage *e=NULL, *res = NULL;
LDAP *ld = NULL;
struct timeval timeout;
// open the connection...
// bind ...
// then search the node....
attrs[0] = "objectGUID";
attrs[1] = "modifyTimeStamp";
attrs[2] = "cn";
attrs[3] = "sAMAccountName";
attrs[4] = "objectClass";
attrs[5] = "name";
attrs[6] = NULL;
snprintf(filter, 1024, "(objectClass=*)");
timeout.tv_sec = 1000;
system("ps aux | grep /myprogram");
ret = ldap_search_ext_s(ld, search_dn, LDAP_SCOPE_BASEOBJECT,filter,
attrs,
0, NULL, NULL, &timeout, 0, &res);
if (ret != LDAP_SUCCESS) {
printf("search node %s error: %s\n", search_dn,
ldap_err2string(ret));
ldap_msgfree(res);
ldap_unbind_ext(ld, NULL, NULL);
return (-1);
}
system("ps aux | grep /myprogram");
#if 1
// get the attribute value of entry.
for (e = ldap_first_entry(ld, res);
e != NULL; e = ldap_next_entry(ld, e)) {
#if 1
BerElement *ptr = NULL;
for (a = ldap_first_attribute(ld, e, &ptr);
a != NULL; a = ldap_next_attribute(ld, e, ptr)) {
// do sth with the attribute.
}// inner for loop
if(ptr != NULL) {
ber_free(ptr,0);
}
#endif
}// outer for loop
#endif
system("ps aux | grep /myprogram");
ldap_msgfree(res);
res = NULL;
system("ps aux | grep /myprogram");
ldap_unbind_ext(ld, NULL, NULL);
return OK;
}