Index: /trunk/Ohana/src/relastro/include/relastro.h
===================================================================
--- /trunk/Ohana/src/relastro/include/relastro.h	(revision 39395)
+++ /trunk/Ohana/src/relastro/include/relastro.h	(revision 39396)
@@ -415,4 +415,6 @@
 void SetProtect (int mode);
 int SetSignals (void);
+
+void relastro_client_free ();
 
 GSCRegion    *find_regions        PROTO((Image *image, off_t Nimage, int *Nregions, GSCRegion *fullregion));
@@ -610,4 +612,5 @@
 int BrightCatalogSplit (CatalogSplitter *catalogs, BrightCatalog *bcatalog);
 int BrightCatalogSplitFree (CatalogSplitter *catalogs);
+void BrightCatalogFree (BrightCatalog *bcatalog);
 
 PhotCode **ParsePhotcodeList (char *rawlist, int *nphotcodes, int needAve);
@@ -774,2 +777,3 @@
 double weight_cauchy (double x);
 double dpsi_cauchy (double x);
+void my_memdump (char *message);
Index: /trunk/Ohana/src/relastro/src/BrightCatalog.c
===================================================================
--- /trunk/Ohana/src/relastro/src/BrightCatalog.c	(revision 39395)
+++ /trunk/Ohana/src/relastro/src/BrightCatalog.c	(revision 39396)
@@ -357,6 +357,12 @@
 
     ohana_memcheck (1);
+
+    my_memdump("start of define_bintable");
     gfits_define_bintable_column (&theader, "D", "RA",       "ra",                         "degrees", 1.0, 0.0);
+    my_memdump("after define_bintable RA");
+
     gfits_define_bintable_column (&theader, "D", "DEC",      "dec",                        "degrees", 1.0, 0.0);
+    my_memdump("after define_bintable DEC");
+
     gfits_define_bintable_column (&theader, "E", "MAG_SYS",  "magnitude (sys)",             NULL,    1.0, 0.0);
     gfits_define_bintable_column (&theader, "E", "MAG_CAL",  "magnitude (cal)",             NULL,    1.0, 0.0);
@@ -771,4 +777,13 @@
 }
 
+void BrightCatalogFree (BrightCatalog *bcatalog) {
+  if (!bcatalog) return;
+  FREE (bcatalog[0].average);
+  FREE (bcatalog[0].measure);
+  FREE (bcatalog[0].secfilt);
+  FREE (bcatalog);
+  return;
+}
+
 // distribute a bright catalog across separate catalogs
 CatalogSplitter *BrightCatalogSplitInit (int Nsecfilt) {
Index: /trunk/Ohana/src/relastro/src/ConfigInit.c
===================================================================
--- /trunk/Ohana/src/relastro/src/ConfigInit.c	(revision 39395)
+++ /trunk/Ohana/src/relastro/src/ConfigInit.c	(revision 39396)
@@ -4,5 +4,5 @@
 
   char  *config, *file;
-  char CatdirPhotcodeFile[256];
+  char CatdirPhotcodeFile[DVO_MAX_PATH];
   struct stat filestat;
   int status;
@@ -61,5 +61,5 @@
   ScanConfig(config, "WHERE_B",                "%s",  0, WHERE_B);
 
-  sprintf (ImageCat, "%s/Images.dat", CATDIR);
+  snprintf (ImageCat, DVO_MAX_PATH, "%s/Images.dat", CATDIR);
 
   if (!ScanConfig (config, "SKY_DEPTH",         "%d",  0, &SKY_DEPTH)) SKY_DEPTH = 2;
@@ -77,5 +77,5 @@
 
   /* update master photcode table if not defined */
-  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
+  snprintf (CatdirPhotcodeFile, DVO_MAX_PATH, "%s/Photcodes.dat", CATDIR);
   if (!LoadPhotcodes (CatdirPhotcodeFile, NULL, FALSE)) {
     fprintf (stderr, "error loading photcode table %s\n", CatdirPhotcodeFile);
@@ -91,4 +91,5 @@
   }
 
+  FreeConfigFile();
   free (config);
   free (file);
Index: /trunk/Ohana/src/relastro/src/SetSignals.c
===================================================================
--- /trunk/Ohana/src/relastro/src/SetSignals.c	(revision 39395)
+++ /trunk/Ohana/src/relastro/src/SetSignals.c	(revision 39396)
@@ -52,4 +52,16 @@
   return (TRUE);
 }
+
+void my_memdump (char *message) {
+
+  fprintf (stderr, "%s\n", message);
+  pid_t myPid = getpid();
+  char line[256];
+  snprintf (line, 256, "cat /proc/%d/maps", myPid);
+  system (line);
+  fprintf (stderr, "-------------------- end ---------------------\n");
+  return;
+}
+
 /*
 
Index: /trunk/Ohana/src/relastro/src/args.c
===================================================================
--- /trunk/Ohana/src/relastro/src/args.c	(revision 39395)
+++ /trunk/Ohana/src/relastro/src/args.c	(revision 39396)
@@ -920,4 +920,20 @@
   if (argc != 1) usage_client ();
   return TRUE;
+}
+
+void relastro_client_free () {
+  FREE (PHOTCODE_SKIP_LIST);
+  FREE (PHOTCODE_KEEP_LIST);
+  FREE (PHOTCODE_RESET_LIST);
+  FREE (DCR_RED_COLOR_POS);
+  FREE (DCR_RED_COLOR_NEG);
+  FREE (DCR_BLUE_COLOR_POS);
+  FREE (DCR_BLUE_COLOR_NEG);
+
+  FREE(PHOTCODE_A_LIST);
+  FREE(PHOTCODE_B_LIST);
+  FREE(HIGH_SPEED_DIR);
+  FREE(BCATALOG);
+  FREE (HOSTDIR);
 }
 
Index: /trunk/Ohana/src/relastro/src/load_catalogs.c
===================================================================
--- /trunk/Ohana/src/relastro/src/load_catalogs.c	(revision 39395)
+++ /trunk/Ohana/src/relastro/src/load_catalogs.c	(revision 39396)
@@ -92,4 +92,8 @@
     }
     Ncat ++;
+
+    char message[1024];
+    snprintf (message, 1024, "loaded catalog: %d", Ncat);
+    my_memdump(message);
   }
 
Index: /trunk/Ohana/src/relastro/src/plotstuff.c
===================================================================
--- /trunk/Ohana/src/relastro/src/plotstuff.c	(revision 39395)
+++ /trunk/Ohana/src/relastro/src/plotstuff.c	(revision 39396)
@@ -25,5 +25,5 @@
   char name[100];
 
-  sprintf (name, "gastro [%d]", N);
+  snprintf (name, 100, "gastro [%d]", N);
   Xgraph[N] = KapaOpen ("kapa", name);
 
Index: /trunk/Ohana/src/relastro/src/relastro_client.c
===================================================================
--- /trunk/Ohana/src/relastro/src/relastro_client.c	(revision 39395)
+++ /trunk/Ohana/src/relastro/src/relastro_client.c	(revision 39396)
@@ -1,3 +1,5 @@
 # include "relastro.h"
+// # include <sys/types.h>
+// # include <unistd.h>
 
 // relastro_client is run on a remote host and is responsible for updating the catalogs
@@ -21,4 +23,6 @@
 int main (int argc, char **argv) {
 
+  my_memdump("start of program");
+
   // get configuration info, args, lockfile (set CATDIR, HOST_ID, HOSTDIR, etc) 
   SetSignals ();
@@ -28,4 +32,6 @@
   SkyTableSetFilenames (sky, CATDIR, "cpt");
   SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch);
+
+  my_memdump("done config");
 
   switch (RELASTRO_OP) {
@@ -39,9 +45,34 @@
 	exit (2);
       }
+      my_memdump("loaded catalogs");
+
       BrightCatalog *bcatalog = BrightCatalogMerge (catalog, Ncatalog);
+      my_memdump("merged bcatalog");
+
       if (!BrightCatalogSave (BCATALOG, bcatalog)) {
 	fprintf (stderr, "ERROR saving bright catalog from %s\n", CATDIR);
 	exit (2);
       }
+
+      SkyTableFree (sky);
+      SkyListFree(skylist);
+      FreePhotcodeTable();
+
+      int i;
+      for (i = 0; i < Ncatalog; i++) {
+	dvo_catalog_free (&catalog[i]);
+      }
+      FREE (catalog);
+      BrightCatalogFree(bcatalog);
+
+      relastro_client_free ();
+      FREE(photcodesKeep);
+      FREE(photcodesSkip);  
+      FREE(photcodesReset); 
+      FREE(photcodesGroupA);
+      FREE(photcodesGroupB);
+
+      ohana_memcheck (TRUE);
+      ohana_memdump (TRUE);
       break;
     }
