[asterisk-commits] rmudgett: trunk r397811 - in /trunk: ./ main/astmm.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Aug 27 13:52:27 CDT 2013
Author: rmudgett
Date: Tue Aug 27 13:52:23 2013
New Revision: 397811
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=397811
Log:
Made MALLOC_DEBUG less CPU intensive by default.
Storing a backtrace for each allocation in anticipation of a memory
management problem is very CPU intensive.
* Added the CLI "memory backtrace {on|off}" command to request that the
backtrace be gathered only on request. The backtrace is off by default.
(issue ASTERISK-22221)
Reported by: Matt Jordan
........
Merged revisions 397809 from http://svn.asterisk.org/svn/asterisk/branches/12
Modified:
trunk/ (props changed)
trunk/main/astmm.c
Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Tue Aug 27 13:52:23 2013
@@ -1,1 +1,1 @@
-/branches/12:1-397673,397690,397713,397745,397759
+/branches/12:1-397673,397690,397713,397745,397759,397809
Modified: trunk/main/astmm.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/astmm.c?view=diff&rev=397811&r1=397810&r2=397811
==============================================================================
--- trunk/main/astmm.c (original)
+++ trunk/main/astmm.c Tue Aug 27 13:52:23 2013
@@ -142,6 +142,8 @@
static enum summary_opts atexit_summary;
/*! Nonzero if the unfreed regions are listed at exit. */
static int atexit_list;
+/*! Nonzero if the memory allocation backtrace is enabled. */
+static int backtrace_enabled;
#define HASH(a) (((unsigned long)(a)) % ARRAY_LEN(regions))
@@ -235,7 +237,7 @@
reg->cache = cache;
reg->lineno = lineno;
reg->which = which;
- reg->bt = ast_bt_create();
+ reg->bt = backtrace_enabled ? ast_bt_create() : NULL;
ast_copy_string(reg->file, file, sizeof(reg->file));
ast_copy_string(reg->func, func, sizeof(reg->func));
@@ -975,11 +977,49 @@
return CLI_SUCCESS;
}
+static char *handle_memory_backtrace(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "memory backtrace";
+ e->usage =
+ "Usage: memory backtrace {on|off}\n"
+ " Enable dumping an allocation backtrace with memory diagnostics.\n"
+ " Note that saving the backtrace data for each allocation\n"
+ " can be CPU intensive.\n";
+ return NULL;
+ case CLI_GENERATE:
+ if (a->pos == 2) {
+ const char * const options[] = { "off", "on", NULL };
+
+ return ast_cli_complete(a->word, options, a->n);
+ }
+ return NULL;
+ }
+
+ if (a->argc != 3) {
+ return CLI_SHOWUSAGE;
+ }
+
+ if (ast_true(a->argv[2])) {
+ backtrace_enabled = 1;
+ } else if (ast_false(a->argv[2])) {
+ backtrace_enabled = 0;
+ } else {
+ return CLI_SHOWUSAGE;
+ }
+
+ ast_cli(a->fd, "The memory backtrace is: %s\n", backtrace_enabled ? "On" : "Off");
+
+ return CLI_SUCCESS;
+}
+
static struct ast_cli_entry cli_memory[] = {
AST_CLI_DEFINE(handle_memory_atexit_list, "Enable memory allocations not freed at exit list."),
AST_CLI_DEFINE(handle_memory_atexit_summary, "Enable memory allocations not freed at exit summary."),
AST_CLI_DEFINE(handle_memory_show_allocations, "Display outstanding memory allocations"),
AST_CLI_DEFINE(handle_memory_show_summary, "Summarize outstanding memory allocations"),
+ AST_CLI_DEFINE(handle_memory_backtrace, "Enable dumping an allocation backtrace with memory diagnostics."),
};
AST_LIST_HEAD_NOLOCK(region_list, ast_region);
More information about the asterisk-commits
mailing list