[Freeswitch-svn] [commit] r12317 - in freeswitch/trunk/src: . mod/applications/mod_conference
FreeSWITCH SVN
anthm at freeswitch.org
Thu Feb 26 14:30:00 PST 2009
Author: anthm
Date: Thu Feb 26 16:30:00 2009
New Revision: 12317
Log:
reduce memory usage
Modified:
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
freeswitch/trunk/src/switch_core_memory.c
freeswitch/trunk/src/switch_event.c
freeswitch/trunk/src/switch_log.c
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Thu Feb 26 16:30:00 2009
@@ -1846,7 +1846,7 @@
int to = 60;
if (ann) {
- member->conference->special_announce = switch_core_strdup(member->conference->pool, ann);
+ member->conference->special_announce = switch_core_strdup(member->pool, ann);
}
switch_channel_set_private(channel, "_conference_autocall_list_", NULL);
@@ -2676,7 +2676,7 @@
if (!conference->sh) {
memset(&conference->lsh, 0, sizeof(conference->lsh));
if (switch_core_speech_open(&conference->lsh, conference->tts_engine, conference->tts_voice,
- conference->rate, conference->interval, &flags, conference->pool) != SWITCH_STATUS_SUCCESS) {
+ conference->rate, conference->interval, &flags, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", conference->tts_engine);
return SWITCH_STATUS_FALSE;
}
Modified: freeswitch/trunk/src/switch_core_memory.c
==============================================================================
--- freeswitch/trunk/src/switch_core_memory.c (original)
+++ freeswitch/trunk/src/switch_core_memory.c Thu Feb 26 16:30:00 2009
@@ -34,7 +34,7 @@
//#define DEBUG_ALLOC
//#define DEBUG_ALLOC2
//#define DESTROY_POOLS
-//#define PER_POOL_LOCK
+#define PER_POOL_LOCK
//#define INSTANTLY_DESTROY_POOLS
#include <switch.h>
Modified: freeswitch/trunk/src/switch_event.c
==============================================================================
--- freeswitch/trunk/src/switch_event.c (original)
+++ freeswitch/trunk/src/switch_event.c Thu Feb 26 16:30:00 2009
@@ -83,8 +83,10 @@
static switch_hash_t *CUSTOM_HASH = NULL;
static int THREAD_COUNT = 0;
static int SYSTEM_RUNNING = 0;
+#ifdef SWITCH_EVENT_RECYCLE
static switch_queue_t *EVENT_RECYCLE_QUEUE = NULL;
static switch_queue_t *EVENT_HEADER_RECYCLE_QUEUE = NULL;
+#endif
static void launch_dispatch_threads(uint32_t max, int len, switch_memory_pool_t *pool);
static char *my_dup(const char *s)
@@ -422,6 +424,8 @@
SWITCH_DECLARE(void) switch_core_memory_reclaim_events(void)
{
+#ifdef SWITCH_EVENT_RECYCLE
+
void *pop;
int size;
size = switch_queue_size(EVENT_RECYCLE_QUEUE);
@@ -437,6 +441,10 @@
while (switch_queue_trypop(EVENT_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS && pop) {
free(pop);
}
+#else
+ return;
+#endif
+
}
SWITCH_DECLARE(switch_status_t) switch_event_shutdown(void)
@@ -569,8 +577,10 @@
switch_queue_create(&EVENT_QUEUE[0], POOL_COUNT_MAX + 10, THRUNTIME_POOL);
switch_queue_create(&EVENT_QUEUE[1], POOL_COUNT_MAX + 10, THRUNTIME_POOL);
switch_queue_create(&EVENT_QUEUE[2], POOL_COUNT_MAX + 10, THRUNTIME_POOL);
+#ifdef SWITCH_EVENT_RECYCLE
switch_queue_create(&EVENT_RECYCLE_QUEUE, 250000, THRUNTIME_POOL);
switch_queue_create(&EVENT_HEADER_RECYCLE_QUEUE, 250000, THRUNTIME_POOL);
+#endif
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_threadattr_priority_increase(thd_attr);
@@ -595,7 +605,9 @@
SWITCH_DECLARE(switch_status_t) switch_event_create_subclass_detailed(const char *file, const char *func, int line,
switch_event_t **event, switch_event_types_t event_id, const char *subclass_name)
{
+#ifdef SWITCH_EVENT_RECYCLE
void *pop;
+#endif
*event = NULL;
@@ -603,12 +615,16 @@
return SWITCH_STATUS_GENERR;
}
+#ifdef SWITCH_EVENT_RECYCLE
if (switch_queue_trypop(EVENT_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS && pop) {
*event = (switch_event_t *) pop;
} else {
+#endif
*event = ALLOC(sizeof(switch_event_t));
switch_assert(*event);
+#ifdef SWITCH_EVENT_RECYCLE
}
+#endif
memset(*event, 0, sizeof(switch_event_t));
@@ -686,9 +702,13 @@
FREE(hp->name);
FREE(hp->value);
memset(hp, 0, sizeof(*hp));
+#ifdef SWITCH_EVENT_RECYCLE
if (switch_queue_trypush(EVENT_HEADER_RECYCLE_QUEUE, hp) != SWITCH_STATUS_SUCCESS) {
FREE(hp);
}
+#else
+ FREE(hp);
+#endif
status = SWITCH_STATUS_SUCCESS;
} else {
lp = hp;
@@ -702,14 +722,18 @@
{
switch_event_header_t *header;
switch_ssize_t hlen = -1;
- void *pop;
+#ifdef SWITCH_EVENT_RECYCLE
+ void *pop;
if (switch_queue_trypop(EVENT_HEADER_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS) {
header = (switch_event_header_t *) pop;
} else {
+#endif
header = ALLOC(sizeof(*header));
switch_assert(header);
+#ifdef SWITCH_EVENT_RECYCLE
}
+#endif
memset(header, 0, sizeof(*header));
@@ -795,17 +819,26 @@
hp = hp->next;
FREE(this->name);
FREE(this->value);
- memset(this, 0, sizeof(*this));
+#ifdef SWITCH_EVENT_RECYCLE
if (switch_queue_trypush(EVENT_HEADER_RECYCLE_QUEUE, this) != SWITCH_STATUS_SUCCESS) {
FREE(this);
}
+#else
+ FREE(this);
+#endif
+
+
}
FREE(ep->body);
FREE(ep->subclass_name);
- memset(ep, 0, sizeof(*ep));
+#ifdef SWITCH_EVENT_RECYCLE
if (switch_queue_trypush(EVENT_RECYCLE_QUEUE, ep) != SWITCH_STATUS_SUCCESS) {
FREE(ep);
}
+#else
+ FREE(ep);
+#endif
+
}
*event = NULL;
}
Modified: freeswitch/trunk/src/switch_log.c
==============================================================================
--- freeswitch/trunk/src/switch_log.c (original)
+++ freeswitch/trunk/src/switch_log.c Thu Feb 26 16:30:00 2009
@@ -58,7 +58,9 @@
static switch_log_binding_t *BINDINGS = NULL;
static switch_mutex_t *BINDLOCK = NULL;
static switch_queue_t *LOG_QUEUE = NULL;
+#ifdef SWITCH_LOG_RECYCLE
static switch_queue_t *LOG_RECYCLE_QUEUE = NULL;
+#endif
static int8_t THREAD_RUNNING = 0;
static uint8_t MAX_LEVEL = 0;
static int mods_loaded = 0;
@@ -226,9 +228,14 @@
switch_mutex_unlock(BINDLOCK);
switch_safe_free(node->data);
+#ifdef SWITCH_LOG_RECYCLE
if (switch_queue_trypush(LOG_RECYCLE_QUEUE, node) != SWITCH_STATUS_SUCCESS) {
free(node);
}
+#else
+ free(node);
+#endif
+
}
THREAD_RUNNING = 0;
@@ -347,14 +354,18 @@
if (do_mods && level <= MAX_LEVEL) {
switch_log_node_t *node;
+#ifdef SWITCH_LOG_RECYCLE
void *pop = NULL;
if (switch_queue_trypop(LOG_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS) {
node = (switch_log_node_t *) pop;
} else {
+#endif
node = malloc(sizeof(*node));
switch_assert(node);
+#ifdef SWITCH_LOG_RECYCLE
}
+#endif
node->data = data;
data = NULL;
@@ -368,9 +379,13 @@
if (switch_queue_trypush(LOG_QUEUE, node) != SWITCH_STATUS_SUCCESS) {
free(node->data);
+#ifdef SWITCH_LOG_RECYCLE
if (switch_queue_trypush(LOG_RECYCLE_QUEUE, node) != SWITCH_STATUS_SUCCESS) {
free(node);
}
+#else
+ free(node);
+#endif
node = NULL;
}
}
@@ -395,7 +410,9 @@
switch_queue_create(&LOG_QUEUE, SWITCH_CORE_QUEUE_LEN, LOG_POOL);
+#ifdef SWITCH_LOG_RECYCLE
switch_queue_create(&LOG_RECYCLE_QUEUE, SWITCH_CORE_QUEUE_LEN, LOG_POOL);
+#endif
switch_mutex_init(&BINDLOCK, SWITCH_MUTEX_NESTED, LOG_POOL);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&thread, thd_attr, log_thread, NULL, LOG_POOL);
@@ -422,6 +439,7 @@
SWITCH_DECLARE(void) switch_core_memory_reclaim_logger(void)
{
+#ifdef SWITCH_LOG_RECYCLE
void *pop;
int size = switch_queue_size(LOG_RECYCLE_QUEUE);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Returning %d recycled log node(s) %d bytes\n", size,
@@ -429,6 +447,10 @@
while (switch_queue_trypop(LOG_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS) {
free(pop);
}
+#else
+ return;
+#endif
+
}
SWITCH_DECLARE(switch_status_t) switch_log_shutdown(void)
More information about the Freeswitch-svn
mailing list