APPROVE COMMIT
NOTE: This patch has been committed.
I’ve been running with this for three weeks without bad consequences. On the
upside, it’s nice not to have your XEmacs abort when it breaks 128 MB; on
the downside, now I get to see output like this from top(1):
load averages: 0.84, 0.98, 0.77 19:52:07
53 processes: 1 runnable, 49 sleeping, 1 stopped, 1 zombie, 1 on processor
CPU states: 2.2% user, 0.0% nice, 0.0% system, 0.6% interrupt, 97.2% idle
Memory: 142M Act, 71M Inact, 804K Wired, 21M Exec, 22M File, 1084K Free
Swap: 628M Total, 228M Used, 400M Free
PID USERNAME PRI NICE SIZE RES STATE TIME WCPU CPU COMMAND
302 aidan 2 0 7868K 8856K select 0:28 0.68% 0.68% beep-media-p
241 aidan 2 0 237M 28M poll 0:30 0.00% 0.00% xemacs-21.5-
Patch addresses the problem seen here:
http://list-archive.xemacs.org/xemacs-beta/200501/msg00147.html ,
16872.7244.893526.907155(a)parhasard.net
src/ChangeLog addition:
2005-12-24 Aidan Kehoe <kehoea(a)parhasard.net>
* alloc.c (MALLOC_BEGIN):
Assert that we're either not in malloc, or warning about memory
being low.
* alloc.c (MALLOC_WARNING_BEGIN, MALLOC_WARNING_END):
Add two clauses to set and clear a flag that we're in a low-memory
warning situation.
* alloc.c (malloc_warning):
Move it after the definition of MALLOC_WARNING_BEGIN,
MALLOC_WARNING_END
XEmacs Trunk source patch:
Diff command: cvs -q diff -u
Files affected: src/alloc.c
Index: src/alloc.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/alloc.c,v
retrieving revision 1.120
diff -u -u -r1.120 alloc.c
--- src/alloc.c 2005/11/25 01:41:55 1.120
+++ src/alloc.c 2005/12/24 18:46:32
@@ -231,22 +231,6 @@
}
#endif /* not MC_ALLOC */
-/* malloc calls this if it finds we are near exhausting storage */
-void
-malloc_warning (const char *str)
-{
- if (ignore_malloc_warnings)
- return;
-
- warn_when_safe
- (Qmemory, Qemergency,
- "%s\n"
- "Killing some buffers may delay running out of memory.\n"
- "However, certainly by the time you receive the 95%% warning,\n"
- "you should clean up, kill this Emacs, and start a new one.",
- str);
-}
-
/* Called if malloc returns zero */
DOESNT_RETURN
memory_full (void)
@@ -290,18 +274,21 @@
}
#ifdef ERROR_CHECK_MALLOC
-static int in_malloc;
+static int in_malloc, in_malloc_warning;
extern int regex_malloc_disallowed;
#define MALLOC_BEGIN() \
do \
{ \
- assert (!in_malloc); \
+ assert (!in_malloc || in_malloc_warning); \
assert (!regex_malloc_disallowed); \
in_malloc = 1; \
} \
while (0)
+#define MALLOC_WARNING_BEGIN() (++in_malloc_warning)
+#define MALLOC_WARNING_END() (--in_malloc_warning)
+
#ifdef MC_ALLOC
#define FREE_OR_REALLOC_BEGIN(block) \
do \
@@ -341,10 +328,33 @@
#else /* ERROR_CHECK_MALLOC */
#define MALLOC_BEGIN()
+#define MALLOC_WARNING_BEGIN()
+#define MALLOC_WARNING_END()
#define FREE_OR_REALLOC_BEGIN(block)
#define MALLOC_END()
#endif /* ERROR_CHECK_MALLOC */
+
+/* malloc calls this if it finds we are near exhausting storage */
+void
+malloc_warning (const char *str)
+{
+ if (ignore_malloc_warnings)
+ return;
+
+ MALLOC_WARNING_BEGIN();
+
+ warn_when_safe
+ (Qmemory, Qemergency,
+ "%s\n"
+ "Killing some buffers may delay running out of memory.\n"
+ "However, certainly by the time you receive the 95%% warning,\n"
+ "you should clean up, kill this Emacs, and start a new one.\n"
+ "On Unix, look into your resource limits; ulimit -d, especially.",
+ str);
+
+ MALLOC_WARNING_END();
+}
static void
malloc_after (void *val, Bytecount size)
--
I AM IN JAIL AND ALLOWED SEND ONLY ONE CABLE SINCE WAS ARRESTED WHILE
MEASURING FIFTEEN FOOT WALL OUTSIDE PALACE AND HAVE JUST FINISHED COUNTING
THIRTY EIGHT THOUSAND FIVE HUNDERED TWENTY TWO NAMES WHOS WHO IN MIDEAST.