diff --git a/include/asterisk/extconf.h b/include/asterisk/extconf.h
index 1a04b01bfb51c1d62648508e2893e70fdbba8a1f..043d24532f5a4e27d34c1a384170f0d67243ad82 100644
--- a/include/asterisk/extconf.h
+++ b/include/asterisk/extconf.h
@@ -220,7 +220,11 @@ enum ext_match_t {
 	E_SPAWN =	0x12,	/* want to spawn an extension. Requires exact match */
 	E_FINDLABEL =	0x22	/* returns the priority for a given label. Requires exact match */
 };
+#ifdef LOW_MEMORY
 #define AST_PBX_MAX_STACK  128
+#else
+#define AST_PBX_MAX_STACK  512
+#endif
 
 /* request and result for pbx_find_extension */
 struct pbx_find_info {
diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h
index 6dea7444a2257aabdebc1fb34b4c2bb9045a8886..1cb05cf728b1fc56913ee95b4cdaea0ca4c52c62 100644
--- a/include/asterisk/pbx.h
+++ b/include/asterisk/pbx.h
@@ -1548,7 +1548,12 @@ enum ext_match_t {
 #define STATUS_NO_PRIORITY	3
 #define STATUS_NO_LABEL		4
 #define STATUS_SUCCESS		5
+
+#ifdef LOW_MEMORY
 #define AST_PBX_MAX_STACK  128
+#else
+#define AST_PBX_MAX_STACK  512
+#endif
 
 /* request and result for pbx_find_extension */
 struct pbx_find_info {