diff --git a/src/server/ChangeLog b/src/server/ChangeLog
index 61e287477d001ef0b7e9e772a5c525d909d13bb3..569795e2abdcfc851a72ade9b16daec234b3e972 100644
--- a/src/server/ChangeLog
+++ b/src/server/ChangeLog
@@ -1,5 +1,15 @@
 Sat Sep 21 02:12:24 1991  Per Cederqvist  (ceder at lysator)
 
+	* ram-smalloc.c: Added support for memory leak finding.
+
+	* trace-mem.gdb, handle-malloc-dump.el: Useful for finding memory 
+	  leaks in the server. Compile ram-smalloc.c with DEBUG_MALLOC
+	  defined.
+
+	* mux.c (mux_close): Fixed memory leak.
+
+	* ramkomd.c (main): Print how many blocks isc allocates.
+
 	* ramkomd.c: ip_client_port and ip_mux_port are local to ramkomd.c.
 
 Tue Sep 17 23:04:39 1991  Per Cederqvist  (ceder at lysator)
diff --git a/src/server/ram-smalloc.c b/src/server/ram-smalloc.c
index 4141c9f9e312aeeeb19bd4f6915204f3d3f3e5f2..c304d8eb79c5c1cfac192137ad6c2011bdbd3b90 100644
--- a/src/server/ram-smalloc.c
+++ b/src/server/ram-smalloc.c
@@ -1,5 +1,5 @@
 /*
- * $Id: ram-smalloc.c,v 0.6 1991/09/15 10:29:31 linus Exp $
+ * $Id: ram-smalloc.c,v 0.7 1991/09/21 12:19:24 ceder Exp $
  * Copyright (C) 1991  Lysator Academic Computer Association.
  *
  * This file is part of the LysKOM server.
@@ -30,7 +30,14 @@
  *	TEST VERSION by ceder
  */
 
-static char *rcsid = "$Id: ram-smalloc.c,v 0.6 1991/09/15 10:29:31 linus Exp $";
+/*
+ * Define DEBUG_MALLOC to get traces from smalloc, srealloc and sfree.
+ * Run the resulting lyskomd under gdb. Source trace-mem.gdb. Run
+ * handle-malloc-dump.el on the resulting output.
+ */
+/* #define DEBUG_MALLOC */
+
+static char *rcsid = "$Id: ram-smalloc.c,v 0.7 1991/09/21 12:19:24 ceder Exp $";
 
 
 #include <stdio.h>
@@ -45,6 +52,16 @@ static char *rcsid = "$Id: ram-smalloc.c,v 0.6 1991/09/15 10:29:31 linus Exp $";
 
 static int no_of_allocated_blocks = 0;
 
+#ifdef DEBUG_MALLOC
+static void
+trace_smalloc(size_t size,
+	      void *result)
+{
+    printf("smalloc:\nArg: 0x%lx\nRes: 0x%lx\n", (long)size, (long)result);
+    printf("==== end ====\n");
+}
+#endif
+
 /*
  * "safe" malloc. Handles the case when malloc returns NULL.
  * smalloc cannot fail.
@@ -64,10 +81,22 @@ smalloc(size_t size)
    *p++ = size;
    ((unsigned char *) p)[size]   = 0x89;
    ((unsigned char *) p)[size+1] = 0xA7;
-   
+
+#ifdef DEBUG_MALLOC
+   trace_smalloc(size, p);
+#endif
+
    return (void *) p;
 }
 
+#ifdef DEBUG_MALLOC
+static void
+trace_free(void *block)
+{
+    printf("sfree:\nArg: 0x%lx\n", (long)block);
+    printf("==== end ====\n");
+}
+#endif
 
 EXPORT  void
 sfree(void * ptr)	/* it is legal to sfree a NULL pointer */
@@ -81,6 +110,9 @@ sfree(void * ptr)	/* it is legal to sfree a NULL pointer */
     
     if ( ptr != NULL )
     {
+#ifdef DEBUG_MALLOC
+	trace_free(ptr);
+#endif
         ip = (unsigned int *) ptr;
 	ip -= 2;
 	switch (*ip)
@@ -103,6 +135,17 @@ sfree(void * ptr)	/* it is legal to sfree a NULL pointer */
     }
 }
 
+#ifdef DEBUG_MALLOC
+static void
+trace_srealloc(size_t size,
+	       void *arg,		   
+	       void *result)
+{
+    printf("srealloc:\nSize: 0x%lx\nArg: 0x%lx\nRes: 0x%lx\n",
+	   (long)size, (long)arg, (long)result);
+    printf("==== end ====\n");
+}
+#endif
 EXPORT  void *
 srealloc(void * ptr, size_t size) /* Never fails. It is legal to */
 {				    /* realloc the NULL ptr. */
@@ -144,7 +187,11 @@ srealloc(void * ptr, size_t size) /* Never fails. It is legal to */
 
     ((unsigned char *) new_ptr)[size]   = 0x89;
     ((unsigned char *) new_ptr)[size+1] = 0xA7;
-   
+
+#ifdef DEBUG_MALLOC
+    trace_srealloc(size, ptr, new_ptr);
+#endif
+
     return (void *) new_ptr;
 }