Index: /branches/eam_branches/ohana.20190329/src/kapa2/Makefile
===================================================================
--- /branches/eam_branches/ohana.20190329/src/kapa2/Makefile	(revision 40779)
+++ /branches/eam_branches/ohana.20190329/src/kapa2/Makefile	(revision 40780)
@@ -42,5 +42,5 @@
 $(SRC)/bDrawObjects.$(ARCH).o	  	  $(SRC)/bDrawFrame.$(ARCH).o         \
 $(SRC)/bDrawLabels.$(ARCH).o              $(SRC)/bDrawIt.$(ARCH).o            \
-$(SRC)/bDrawImage.$(ARCH).o               \
+$(SRC)/bDrawImage.$(ARCH).o               $(SRC)/MemoryDump.$(ARCH).o	      \
 $(SRC)/PNGit.$(ARCH).o                    $(SRC)/PPMit.$(ARCH).o	      \
 $(SRC)/PSit.$(ARCH).o                     $(SRC)/CrossHairs.$(ARCH).o         \
Index: /branches/eam_branches/ohana.20190329/src/kapa2/include/prototypes.h
===================================================================
--- /branches/eam_branches/ohana.20190329/src/kapa2/include/prototypes.h	(revision 40779)
+++ /branches/eam_branches/ohana.20190329/src/kapa2/include/prototypes.h	(revision 40780)
@@ -6,4 +6,9 @@
 int	      EventLoop		  PROTO((void));
 void	      CloseDisplay	  PROTO((void));
+int           MemoryDump          PROTO((int sock));
+int           MemoryDumpLines     PROTO((int sock));
+int           MemoryDumpOnExit    PROTO((int sock));
+int           MemoryDumpSetOnExit PROTO((int state));
+int           MemoryDumpAndExit   PROTO((void));
 
 /* SetUpGraphic */
Index: /branches/eam_branches/ohana.20190329/src/kapa2/src/CheckPipe.c
===================================================================
--- /branches/eam_branches/ohana.20190329/src/kapa2/src/CheckPipe.c	(revision 40779)
+++ /branches/eam_branches/ohana.20190329/src/kapa2/src/CheckPipe.c	(revision 40780)
@@ -358,4 +358,22 @@
   }
 
+  if (!strcmp (word, "MEMD")) {
+    MemoryDump (sock);
+    KiiSendCommand (sock, 4, "DONE");
+    FINISHED (TRUE);
+  }
+
+  if (!strcmp (word, "MEML")) {
+    MemoryDumpLines (sock);
+    KiiSendCommand (sock, 4, "DONE");
+    FINISHED (TRUE);
+  }
+
+  if (!strcmp (word, "MEMX")) {
+    MemoryDumpOnExit (sock);
+    KiiSendCommand (sock, 4, "DONE");
+    FINISHED (TRUE);
+  }
+
   fprintf (stderr, "unknown signal %s\n", word);
   KiiSendCommand (sock, 4, "DONE");
Index: /branches/eam_branches/ohana.20190329/src/kapa2/src/MemoryDump.c
===================================================================
--- /branches/eam_branches/ohana.20190329/src/kapa2/src/MemoryDump.c	(revision 40780)
+++ /branches/eam_branches/ohana.20190329/src/kapa2/src/MemoryDump.c	(revision 40780)
@@ -0,0 +1,41 @@
+# include "Ximage.h"
+
+static int DumpOnExit = FALSE;
+
+int MemoryDump (int sock) {
+  OHANA_UNUSED_PARAM(sock);
+
+  ohana_memdump_file (stderr, TRUE);
+
+  return TRUE;
+}
+
+int MemoryDumpLines (int sock) {
+
+  int Nlines;
+  KiiScanMessage (sock, "%d", &Nlines);
+
+  ohana_memdump_set_maxlines (Nlines);
+
+  return TRUE;
+}
+
+int MemoryDumpOnExit (int sock) {
+  OHANA_UNUSED_PARAM(sock);
+
+  int state;
+  KiiScanMessage (sock, "%d", &state);
+
+  MemoryDumpSetOnExit (state);
+  return TRUE;
+}
+
+int MemoryDumpSetOnExit (int state) {
+  DumpOnExit = state;
+  return TRUE;
+}
+
+int MemoryDumpAndExit (void) {
+  if (DumpOnExit) MemoryDump(0);
+  exit (0);
+}
Index: /branches/eam_branches/ohana.20190329/src/kapa2/src/args.c
===================================================================
--- /branches/eam_branches/ohana.20190329/src/kapa2/src/args.c	(revision 40779)
+++ /branches/eam_branches/ohana.20190329/src/kapa2/src/args.c	(revision 40780)
@@ -23,4 +23,9 @@
     NAME_WINDOW = strcreate (argv[N]);
     remove_argument(N, argc, argv);
+  }
+
+  if ((N = get_argument (*argc, argv, "-memdump"))) {
+    remove_argument(N, argc, argv);
+    MemoryDumpSetOnExit (TRUE);
   }
 
Index: /branches/eam_branches/ohana.20190329/src/kapa2/src/bDrawIt.c
===================================================================
--- /branches/eam_branches/ohana.20190329/src/kapa2/src/bDrawIt.c	(revision 40779)
+++ /branches/eam_branches/ohana.20190329/src/kapa2/src/bDrawIt.c	(revision 40780)
@@ -36,4 +36,6 @@
   // apply anti-aliasing only to the graph
   if (graphic->smooth_sigma > 0.0) {
+    // XXX getting a strange value
+    graphic->smooth_sigma = MAX (graphic->smooth_sigma, 5.0);
     bDrawSmooth (graph, graphic->smooth_sigma);
   }
Index: /branches/eam_branches/ohana.20190329/src/kapa2/src/kapa.c
===================================================================
--- /branches/eam_branches/ohana.20190329/src/kapa2/src/kapa.c	(revision 40779)
+++ /branches/eam_branches/ohana.20190329/src/kapa2/src/kapa.c	(revision 40780)
@@ -11,4 +11,4 @@
 
   CloseDisplay ();
-  exit (0);
+  MemoryDumpAndExit ();
 }
Index: /branches/eam_branches/ohana.20190329/src/libkapa/include/kapa.h
===================================================================
--- /branches/eam_branches/ohana.20190329/src/libkapa/include/kapa.h	(revision 40779)
+++ /branches/eam_branches/ohana.20190329/src/libkapa/include/kapa.h	(revision 40780)
@@ -259,4 +259,7 @@
 int KapaSetToolbox (int fd, int location);
 int KapaSetSmoothSigma (int fd, float sigma);
+int KapaMemoryDump (int fd);
+int KapaMemoryDumpLines (int fd, int Nlines);
+int KapaMemoryDumpOnExit (int fd, int state);
 
 /* KapaColors */
Index: /branches/eam_branches/ohana.20190329/src/libkapa/src/KapaWindow.c
===================================================================
--- /branches/eam_branches/ohana.20190329/src/libkapa/src/KapaWindow.c	(revision 40779)
+++ /branches/eam_branches/ohana.20190329/src/libkapa/src/KapaWindow.c	(revision 40780)
@@ -462,2 +462,26 @@
   return (TRUE);
 }
+
+int KapaMemoryDump (int fd) {
+
+  KiiSendCommand (fd, 4, "MEMD");
+  KiiWaitAnswer (fd, "DONE");
+  return (TRUE);
+}
+
+int KapaMemoryDumpLines (int fd, int Nlines) {
+
+  KiiSendCommand (fd, 4, "MEML");
+  KiiSendMessage (fd, "%d ", Nlines);
+  KiiWaitAnswer (fd, "DONE");
+  return (TRUE);
+}
+
+int KapaMemoryDumpOnExit (int fd, int state) {
+
+  KiiSendCommand (fd, 4, "MEMX");
+  KiiSendMessage (fd, "%d ", state);
+  KiiWaitAnswer (fd, "DONE");
+  return (TRUE);
+}
+
Index: /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/Makefile
===================================================================
--- /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/Makefile	(revision 40779)
+++ /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/Makefile	(revision 40780)
@@ -79,4 +79,5 @@
 $(SRC)/join.$(ARCH).o		\
 $(SRC)/jpeg.$(ARCH).o		\
+$(SRC)/kapamemory.$(ARCH).o		\
 $(SRC)/kern.$(ARCH).o		\
 $(SRC)/keyword.$(ARCH).o	\
Index: /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/init.c
===================================================================
--- /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/init.c	(revision 40779)
+++ /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/init.c	(revision 40780)
@@ -68,4 +68,5 @@
 int join             PROTO((int, char **));
 int jpeg             PROTO((int, char **));
+int kapamemory       PROTO((int, char **));
 int kern             PROTO((int, char **));
 int keyword          PROTO((int, char **));
@@ -264,4 +265,5 @@
   {1, "join",         join,             "find the join of two ID vectors"},
   {1, "jpeg",         jpeg,             "convert display image to JPEG"},
+  {1, "kapamemory",   kapamemory,       "manage kapa memory dump options"},
   {1, "kern",         kern,             "convolve with 3x3 kernel"},
   {1, "keyword",      keyword,          "extract a FITS keyword from image header"},
Index: /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/kapamemory.c
===================================================================
--- /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/kapamemory.c	(revision 40780)
+++ /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/kapamemory.c	(revision 40780)
@@ -0,0 +1,56 @@
+# include "data.h"
+
+int kapamemory (int argc, char **argv) {
+
+  int N, kapa;
+
+  /* display source */
+  char *name = NULL;
+  if ((N = get_argument (argc, argv, "-n"))) {
+    remove_argument (N, &argc, argv);
+    name = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if (!GetImage (NULL, &kapa, name)) return (FALSE);
+  FREE (name);
+
+  if (argc < 2) {
+    gprint (GP_ERR, "USAGE: kapamemory (mode)\n");
+    gprint (GP_ERR, "  mode = dump, nlines, exit\n");
+    return (FALSE);
+  }
+
+  if (!strcasecmp(argv[1], "dump")) {
+    KapaMemoryDump (kapa);
+    return TRUE;
+  }
+
+  if (!strcasecmp(argv[1], "exit")) {
+    if (argc != 3) goto exit_usage;
+    if (!strcasecmp(argv[2], "on")) {
+      KapaMemoryDumpOnExit (kapa, TRUE);
+      return TRUE;
+    }
+    if (!strcasecmp(argv[2], "off")) {
+      KapaMemoryDumpOnExit (kapa, FALSE);
+      return TRUE;
+    }
+  exit_usage:
+    gprint (GP_ERR, "USAGE: kapamemory exit (status)\n");
+    gprint (GP_ERR, "  statue = 'on' or 'off'\n");
+    return FALSE;
+  }
+
+  if (!strcasecmp(argv[1], "nlines")) {
+    if (argc != 3) {
+      gprint (GP_ERR, "USAGE: kapamemory nlines (N)\n");
+      return FALSE;
+    }
+    int Nlines = atoi (argv[2]);
+    KapaMemoryDumpLines (kapa, Nlines);
+    return TRUE;
+  }
+  gprint (GP_ERR, "ERROR: unknown kapamemory mode %s\n", argv[1]);
+  return FALSE;
+}
+
