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

Re: malloc: Cannot allocate memory





--On Wednesday, November 02, 2005 8:15 PM -0500 Dusty Doris <openldap@mail.doris.cc> wrote:

Hey all,

With openldap 2.3 in production for several weeks now, I experienced my
first crash of slapd today.  I have my loglevel at 256 and was able to
find this in the logs.

Started with a bunch of these:
Nov  2 18:00:41 ldap1 slapd[1525]: bdb(dc=fuse,dc=net): malloc: Cannot
allocate memory: 377

Finally ended with:
Nov  2 18:00:41 ldap1 slapd[1525]: ch_calloc of 1 elems of 392 bytes
failed


I've received this error when slapd was unable to allocate memory (usually by there being no free memory left on the system). This could well be caused by faulty memory chips...


Now that I think about it, that 100,000/300,000 might be a bit high.
What do you think?  Could that cause the memory error?  I'm not sure if
this cache is related to the cachesize in DB_CONFIG - I'm assuming this
uses extra memory outside the DB_CONFIG size.  Is that correct?

Yes, it uses extra memory outside of DB_CONFIG.

My DB_CONFIG file has the following:

set_cachesize 0 536870912 1
set_lg_regionmax 1048576
set_lg_bsize 2097152
set_lg_max 10485760
set_flags DB_LOG_AUTOREMOVE

Since I've got 2G of RAM, I could up that 512M cachesize higher if needed
and mayble lower the cachesize in slapd.conf.  Do you think that would
help?

Here is top, sorted by res about an hour after the restart:
Mem: 217M Active, 1051M Inact, 164M Wired, 80M Cache, 112M Buf, 492M Free
Swap: 1024M Total, 1024M Free
   PID USERNAME PRI NICE   SIZE    RES STATE  C   TIME   WCPU    CPU
COMMAND
33669 ldap      20    0   756M   395M kserel 0   0:25  0.00%  0.00% slapd

Any suggestions?

This shows that slapd is only taking up 395MB of your free memory, which isn't a whole lot.


When you get a chance to experiment, what I would do is set up a server that's identical, and then run a script to load your entire database up into cache (just an ldapsearch across every entry via objectclass=* or something should do...).

That should give you an idea of your maximum memory usage.

I personally run a script on my directory servers that monitors total memory usage, and pages me when it gets too high. This was more a problem in the mid-2.2 releases when there were many memory leaks than in later releases. You may want to consider something similar. A basic concept script is on my website <http://www.stanford.edu/services/directory/openldap/configuration/> under the monitoring section.

--Quanah

--
Quanah Gibson-Mount
Principal Software Developer
ITSS/Shared Services
Stanford University
GnuPG Public Key: http://www.stanford.edu/~quanah/pgp.html

"These censorship operations against schools and libraries are stronger
than ever in the present religio-political climate. They often focus on
fantasy and sf books, which foster that deadly enemy to bigotry and blind
faith, the imagination." -- Ursula K. Le Guin