Hello All;
 Kamailio V4.3.2 gives errors "out of memory" after 339000 calls.my server has centos 6.6 and 2.6.32-573.3.1.el6.x86_64 kernel version. How can we solve this problem. do i set memdb=1 and then try again?

Thanks


Starting with this error;

Sep 24 12:38:50 localhost /usr/local/sbin/kamailio[3518]: ERROR: <core> [msg_translator.c:2127]: build_req_buf_from_sip_req(): out of memory
Sep 24 12:38:50 localhost /usr/local/sbin/kamailio[3518]: ERROR: <core> [forward.c:548]: forward_request(): building failed
Sep 24 12:38:50 localhost /usr/local/sbin/kamailio[3518]: ERROR: sl [sl_funcs.c:363]: sl_reply_error(): ERROR: sl_reply_error used: No error (2/SL)
Sep 24 12:39:06 localhost /usr/local/sbin/kamailio[3514]: ERROR: <core> [parser/parse_rr.c:63]: do_parse_rr_body(): parse_rr(): No memory left
..
..
..
Sep 24 12:39:02 localhost /usr/local/sbin/kamailio[3484]: ERROR: <core> [parser/msg_parser.c:329]: parse_headers(): ERROR:parse_headers: memory allocation error
Sep 24 12:39:02 localhost /usr/local/sbin/kamailio[3484]: ERROR: dialog [dlg_handlers.c:208]: populate_leg_info(): bad sip message or missing Contact hdr
Sep 24 12:39:02 localhost /usr/local/sbin/kamailio[3484]: ERROR: dialog [dlg_handlers.c:488]: dlg_onreply(): could not add further info to the dialog
Sep 24 12:39:02 localhost /usr/local/sbin/kamailio[3484]: ERROR: acc [acc_extra.c:267]: extra2strar(): extra2strar: out of memory.
Sep 24 12:39:02 localhost /usr/local/sbin/kamailio[3484]: ERROR: acc [acc_extra.c:267]: extra2strar(): extra2strar: out of memory.
..
..
..

Sep 24 12:39:06 localhost /usr/local/sbin/kamailio[3514]: ERROR: <core> [parser/parse_rr.c:360]: print_rr_body(): failed to parse RR
Sep 24 12:39:06 localhost /usr/local/sbin/kamailio[3514]: ERROR: dialog [dlg_handlers.c:239]: populate_leg_info(): failed to print route records
Sep 24 12:39:06 localhost /usr/local/sbin/kamailio[3514]: ERROR: dialog [dlg_handlers.c:488]: dlg_onreply(): could not add further info to the dialog
Sep 24 12:39:06 localhost /usr/local/sbin/kamailio[3514]: ERROR: acc [acc_extra.c:267]: extra2strar(): extra2strar: out of memory.
Sep 24 12:39:06 localhost /usr/local/sbin/kamailio[3514]: ERROR: acc [acc_extra.c:267]: extra2strar(): extra2strar: out of memory.
...
...
Going like that.
--
kamailio.cfg
------------

#!KAMAILIO
#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_CARR
#!define WITH_ACC
##!define WITH_ACCDB
#!define WITH_DIALOG
#!define WITH_ACCDB_COMMENT
#!define WITH_IPAUTH
#!define WITH_MULTIDOMAIN
#!define WITH_SAYAC
##!define WITH_BLCKLST
#!define WITH_NAT
#!define WITH_UTILS
#!define WITH_RECORDR

##!define WITH_JSN
##!define WITH_XMLRPC
##!define WITH_PIKE
#!define WITH_RAD


### LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR
#!ifdef WITH_DEBUG
debug=4
log_stderror=yes
#!else
debug=0
log_stderror=no
#!endif

memdbg=5
memlog=5

log_facility=LOG_LOCAL0

fork=yes
children=64

disable_sctp=yes
udp4_raw = on

port=5061

#!ifdef WITH_TLS
enable_tls=yes
#!endif

# life time of TCP connection when there is no traffic
# - a bit higher than registration expires to cope with UA behind NAT
tcp_connection_lifetime=3605

####### Custom Parameters #########

# These parameters can be modified runtime via RPC interface
# - see the documentation of 'cfg_rpc' module.
#
# Format: group.id = value 'desc' description
# Access: $sel(cfg_get.group.id) or @cfg_get.group.id
#


####### Modules Section ########

# set paths to location of modules (to sources or installation folders)
#!ifdef WITH_SRCPATH
mpath="modules/"
#!else
mpath="/usr/local/lib64/kamailio/modules/"
#!endif

#!ifdef WITH_MYSQL
loadmodule "db_mysql.so"
#!endif
loadmodule "mi_fifo.so"
loadmodule "kex.so"
loadmodule "corex.so"
loadmodule "tm.so"
loadmodule "tmx.so"
loadmodule "sl.so"
#!ifdef WITH_RECORDR
loadmodule "rr.so"
#!endif
loadmodule "pv.so"
loadmodule "maxfwd.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "textops.so"
loadmodule "siputils.so"
loadmodule "xlog.so"
loadmodule "sanity.so"
loadmodule "ctl.so"
loadmodule "cfg_rpc.so"
loadmodule "mi_rpc.so"
loadmodule "acc.so"
loadmodule "db_flatstore.so"

#!ifdef WITH_RAD
loadmodule "misc_radius.so"
loadmodule "acc_radius.so"
#!endif
#!ifdef WITH_JSN
loadmodule "json.so"
#!endif

#!ifdef WITH_UTILS
loadmodule "cfgutils.so"
loadmodule "utils.so"
#!endif

#!ifdef WITH_AUTH
loadmodule "auth.so"
loadmodule "auth_db.so"
#!ifdef WITH_IPAUTH
loadmodule "permissions.so"
#!endif
#!endif

#!ifdef WITH_ALIASDB
loadmodule "alias_db.so"
#!endif

#!ifdef WITH_SPEEDDIAL
loadmodule "speeddial.so"
#!endif

#!ifdef WITH_MULTIDOMAIN
loadmodule "domain.so"
#!endif

#!ifdef WITH_NAT
loadmodule "nathelper.so"
loadmodule "rtpproxy.so"
#!endif

#!ifdef WITH_TLS
loadmodule "tls.so"
#!endif

loadmodule "htable.so"

#!ifdef WITH_GRP
loadmodule "group.so"
#!endif


#!ifdef WITH_ANTIFLOOD
loadmodule "pike.so"
#!endif

#!ifdef WITH_XMLRPC
loadmodule "xmlrpc.so"
#!endif

#!ifdef WITH_DEBUG
loadmodule "debugger.so"
#!endif

#!ifdef WITH_CARR
loadmodule "carrierroute.so"
#!endif

#!ifdef WITH_DIALOG
loadmodule "dialog.so"
#!endif

#!ifdef WITH_BLCKLST
loadmodule "userblacklist.so"
#!endif

#!ifdef WITH_LIMIT
loadmodule "ratelimit.so"
loadmodule "pipelimit.so"
#!endif
#!ifdef WITH_PIKE
loadmodule "pike.so"
#!endif
# ----------------- setting module-specific parameters ---------------

#!ifdef WITH_PIKE
modparam("pike", "sampling_time_unit", 2)
modparam("pike", "reqs_density_per_unit", 100)
modparam("pike", "remove_latency", 300)
#!endif

#!ifdef WITH_BLCKLST
modparam("userblacklist", "db_url",DBURL)
modparam("userblacklist", "match_mode", 128)
modparam("userblacklist", "use_domain", 1)
#!endif

#!ifdef WITH_CARR
modparam("carrierroute","config_source","db")
modparam("carrierroute","db_url",DBURL)
modparam("carrierroute","carrierroute_table","carrierroute")
modparam("carrierroute","default_tree","default")
## tekrar yuklenirken cabuk olsun diye asagidaki limit yazilabilir.
modparam("carrierroute", "fetch_rows", 2000)
modparam("carrierroute", "subscriber_table", "subscriber")
modparam("carrierroute", "subscriber_user_col", "username")
modparam("carrierroute", "subscriber_carrier_col", "cr_preferred_carrier")
#!endif



# ----- mi_fifo params -----
modparam("mi_fifo", "fifo_name", "/var/run/kamailio/kamailio_fifo")


# ----- tm params -----
# auto-discard branches from previous serial forking leg
modparam("tm", "failure_reply_mode", 3)
# default retransmission timeout: 30sec
modparam("tm", "fr_timer", 30000)
# default invite retransmission timeout after 1xx: 120sec
modparam("tm", "fr_inv_timer", 120000)

#!ifdef WITH_RECORDR
# ----- rr params -----
# add value to ;lr param to cope with most of the UAs
modparam("rr", "enable_full_lr", 0)
# do not append from tag to the RR (no need for this script)
modparam("rr", "append_fromtag", 1)
modparam("rr", "enable_socket_mismatch_warning", 1)
modparam("rr", "enable_double_rr", 0)
#!endif
# ----- registrar params -----
modparam("registrar", "method_filtering", 1)
/* uncomment the next line to disable parallel forking via location */
# modparam("registrar", "append_branches", 0)
/* uncomment the next line not to allow more than 10 contacts per AOR */
#modparam("registrar", "max_contacts", 10)
# max value for expires of registrations
modparam("registrar", "max_expires", 3600)
# set it to 1 to enable GRUU
modparam("registrar", "gruu_enabled", 0)


# ----- acc params -----
/* what special events should be accounted ? */
modparam("acc", "early_media", 0)
modparam("acc", "report_ack", 1)
modparam("acc", "report_cancels", 1)
modparam("acc", "detect_direction", 0)
modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)
modparam("acc", "log_extra","src_user=$fU;src_domain=$fd;src_ip=$si;dst_user=$rU;dst_domain=$rd;src_ousername=$avp(poparty);networkdatetime=$avp(networkdatetime);dst_ouser=$avp(ptparty);provider=$avp(pprovider);m_id=$avp(maliyet_id);tibtip=$avp(tibtip);src_userid=$avp(userid);dst_userid=$avp(dst_userid);flags=$avp(ucrflag);op_kodu=$avp(op_kodu);lifetime=$avp(i:77);uniqueid=$avp(unique_id);servis=$avp(servis);numbasekle=$avp(69)")
modparam("acc", "log_flag", FLT_ACC)
modparam("acc", "db_missed_flag", FLT_ACCMISSED)
modparam("acc", "acc_time_column", "calldatetime")



#!ifdef WITH_ACCDB
modparam("acc", "cdr_enable", 1)
modparam("acc", "early_media", 0)
modparam("acc", "report_ack", 1)
modparam("acc", "report_cancels", 1)
modparam("acc", "detect_direction", 0)
modparam("acc", "db_url", DBURLCDR)
modparam("acc", "log_flag", FLT_ACC)
modparam("acc", "db_missed_flag", FLT_ACCMISSED)
modparam("acc", "db_table_missed_calls", "missed_calls")
modparam("acc", "db_flag", 1)
modparam("acc", "db_missed_flag", 3)
modparam("acc", "acc_time_column", "calldatetime")
#modparam("acc", "time_mode", 2)
#modparam("acc", "time_exten", "micorsecs")
#modparam("acc", "time_attr", "seconds")
modparam("acc", "db_extra","src_user=$fU;src_domain=$fd;src_ip=$si;dst_user=$rU;dst_domain=$rd;src_ousername=$avp(poparty);networkdatetime=$avp(networkdatetime);dst_ouser=$avp(ptparty);provider=$avp(pprovider);m_id=$avp(maliyet_id);tibtip=$avp(tibtip);src_userid=$avp(userid);dst_userid=$avp(dst_userid);flags=$avp(ucrflag);op_kodu=$avp(op_kodu);lifetime=$avp(i:77);uniqueid=$avp(unique_id);servis=$avp(servis);numbasekle=$avp(69)")
#!endif


#!ifdef WITH_RAD
modparam("acc_radius", "radius_config","/etc/radiusclient/radiusclient.conf")
modparam("acc_radius", "radius_flag", FLT_ACC)
modparam("acc_radius", "radius_missed_flag", FLT_ACCMISSED)
modparam("acc_radius", "service_type", 15)
modparam("acc_radius", "radius_extra", "src_ip=$si;Sip-Uri-User=$fu;provider=$avp(pprovider);uniqueid=$avp(unique_id);src_user=$fU;dst_user=$rU;dst_domain=$rd;src_ousername=$avp(poparty);networkdatetime=$avp(networkdatetime);dst_ouser=$avp(ptparty);m_id=$avp(maliyet_id);tibtip=$avp(tibtip);src_userid=$avp(userid);dst_userid=$avp(dst_userid);flags=$avp(ucrflag);op_kodu=$avp(op_kodu);lifetime=$avp(i:77);servis=$avp(servis);numbasekle=$_s($avp(69))")

modparam("misc_radius", "radius_config", "/etc/radiusclient/radiusclient.conf")
modparam("misc_radius", "group_service_type", 12)
modparam("misc_radius", "uri_service_type", 10)
modparam("misc_radius", "caller_service_type", 30)
modparam("misc_radius", "callee_service_type", 31)
#Arayan
modparam("misc_radius", "caller_extra", "Calling-Station-Id=$ci;Acct-Status-Type=$avp(ucrflag);Acct-Multi-Session-Id=$rU;Acct-Delay-Time=$avp(servis)")
#Aranan
modparam("misc_radius", "callee_extra", "Called-Station-Id=$ci;Acct-Status-Type=$avp(ucrflag);Acct-Multi-Session-Id=$rU;Acct-Delay-Time=$avp(servis)")


modparam("misc_radius", "uri_extra", "Called-Station-Id=$tu")
modparam("misc_radius", "common_response", 0)

#!endif
# ----- usrloc params -----
/* enable DB persistency for location entries */
#!ifdef WITH_USRLOCDB
modparam("usrloc", "db_url", DBURL)
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "use_domain", MULTIDOMAIN)
#!endif


# ----- auth_db params -----
#!ifdef WITH_AUTH
modparam("auth_db", "db_url", DBURL)
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "sippasswd")
modparam("auth_db", "load_credentials", "$avp(userid)=userid")
modparam("auth_db", "use_domain", MULTIDOMAIN)

# ----- permissions params -----
#!ifdef WITH_IPAUTH
modparam("permissions", "db_url", DBURL)
modparam("permissions", "db_mode", 1)
modparam("permissions", "peer_tag_avp", "$avp(i:770)")
#!endif

#!endif


# ----- alias_db params -----
#!ifdef WITH_ALIASDB
modparam("alias_db", "db_url", DBURL)
modparam("alias_db", "use_domain", MULTIDOMAIN)
#!endif


# ----- speeddial params -----
#!ifdef WITH_SPEEDDIAL
modparam("speeddial", "db_url", DBURL)
modparam("speeddial", "use_domain", MULTIDOMAIN)
#!endif


# ----- domain params -----
#!ifdef WITH_MULTIDOMAIN
modparam("domain", "db_url", DBURL)
# register callback to match myself condition with domains list
modparam("domain", "register_myself", 0)
#!endif

#!ifdef WITH_NAT
# ----- rtpproxy params -----
#modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")

# ----- nathelper params -----
modparam("nathelper", "natping_interval", 30)
modparam("nathelper", "ping_nated_only", 1)
modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)
modparam("nathelper", "sipping_from", "sip:pinger@kamailio.org")

# params needed for NAT traversal in other modules
modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
modparam("usrloc", "nat_bflag", FLB_NATB)
#!endif

#!ifdef WITH_TLS
# ----- tls params -----
modparam("tls", "config", "/usr/local/etc/kamailio/tls.cfg")
#!endif

#!ifdef WITH_ANTIFLOOD
# ----- pike params -----
modparam("pike", "sampling_time_unit", 10)
modparam("pike", "reqs_density_per_unit", 1000)
modparam("pike", "remove_latency", 120)

# ----- htable params -----
# ip ban htable with autoexpire after 5 minutes
modparam("htable", "htable", "ipban=>size=8;autoexpire=300;")
#!endif

#!ifdef WITH_XMLRPC
# ----- xmlrpc params -----
modparam("xmlrpc", "route", "XMLRPC");
modparam("xmlrpc", "url_match", "^/RPC")
#!endif

#!ifdef WITH_DEBUG
# ----- debugger params -----
modparam("debugger", "cfgtrace", 1)
#!endif
#---------------- dialog params -------------
#!ifdef WITH_DIALOG
modparam("dialog", "enable_stats", 1)
modparam("dialog", "hash_size", 4096)
modparam("dialog", "rr_param", "did")
modparam("dialog", "dlg_flag",4)
modparam("dialog", "timeout_avp", "$avp(i:10)")
modparam("dialog", "dlg_match_mode", 1)
modparam("dialog", "default_timeout", 3600)
modparam("dialog", "detect_spirals", 1)
modparam("dialog", "profiles_no_value", "inbound")
modparam("dialog", "profiles_with_value", "userid ; opkodu ; useropkodu ")
modparam("dialog", "dlg_extra_hdrs", "Hint: Hell Yeah\r\n")
modparam("dialog", "send_bye", 1)
modparam("dialog", "db_url", DBURL)
modparam("dialog", "db_mode", 3)
modparam("dialog", "db_fetch_rows", 500)
#!endif

#!ifdef WITH_SAYAC
modparam("htable", "htable","sayac=>size=16;dbtable=htable;initval=0;")
modparam("htable", "db_url", DBURL)
modparam("htable", "fetch_rows", 1000)
#!endif

#!ifdef WITH_GRP
modparam("group", "db_url", DBURL)
modparam("group", "use_domain", 0)
#!endif

#!ifdef WITH_UTILS
modparam("utils", "http_query_timeout", 4)
modparam("utils", "forward_active", 0)
#!endif