Splitting debug and debug-memory configure options.
diff --git a/auto/cc b/auto/cc
index 3ffb64c..02c04a7 100644
--- a/auto/cc
+++ b/auto/cc
@@ -170,8 +170,10 @@
 esac
 
 if [ "$NJS_DEBUG" = "YES" ]; then
-        NJS_CC_OPT="$NJS_CC_OPT -O0"
         njs_define=NJS_DEBUG . auto/define
+fi
+
+if [ "$NJS_DEBUG_MEMORY" = "YES" ]; then
         njs_define=NJS_DEBUG_MEMORY . auto/define
 fi
 
diff --git a/auto/help b/auto/help
index c9c307c..ac20f7b 100644
--- a/auto/help
+++ b/auto/help
@@ -16,6 +16,8 @@
 
   --debug=YES               enables additional runtime checks, \
 default: "$NJS_DEBUG"
+  --debug-memory=YES        enables memory alloc debug, \
+default: "$NJS_DEBUG_MEMORY"
   --address-sanitizer=YES   enables build with address sanitizer, \
 default: "$NJS_ADDRESS_SANITIZER"
 END
diff --git a/auto/options b/auto/options
index a7495b8..021f735 100644
--- a/auto/options
+++ b/auto/options
@@ -7,6 +7,7 @@
 NJS_LD_OPT=${NJS_CC_OPT:--O}
 
 NJS_DEBUG=NO
+NJS_DEBUG_MEMORY=NO
 NJS_ADDRESS_SANITIZER=NO
 
 NJS_CONFIGURE_OPTIONS=
@@ -25,6 +26,7 @@
         --ar=*)                          AR="$value"                         ;;
 
         --debug=*)                       NJS_DEBUG="$value"                  ;;
+        --debug-memory=*)                NJS_DEBUG_MEMORY="$value"           ;;
         --address-sanitizer=*)           NJS_ADDRESS_SANITIZER="$value"      ;;
 
         --help)