Index: /branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/ImageMagIO.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/ImageMagIO.c	(revision 36617)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/ImageMagIO.c	(revision 36618)
@@ -53,6 +53,6 @@
   fclose (f);
 
-  // a bit annoying : we read the entire block of data, then extract the columns, then set the image structure values.
-  // this means I need 3 copies in memory at some point.  ugh.
+  // we read the entire block of data, then extract the columns, then set the image structure values.
+  // I free the FITS table data after extracting the colums to avoid having 3 copies in memory.
 
   char type[16];
@@ -66,4 +66,10 @@
   GET_COLUMN (ubercalDist,       "UDIST",            int);
   GET_COLUMN (imageID,           "ID",               int);
+
+  // free the memory associated with the FITS files
+  gfits_free_header (&header);
+  gfits_free_matrix (&matrix);
+  gfits_free_header (&theader);
+  gfits_free_table (&ftable);
 
   ALLOCATE (image_mags, ImageMag, Nrow);
Index: /branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/MeanMagIO.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/MeanMagIO.c	(revision 36617)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/MeanMagIO.c	(revision 36618)
@@ -64,4 +64,10 @@
   GET_COLUMN (objID, 	 "OBJ_ID",       int);
   GET_COLUMN (catID, 	 "CAT_ID",       int);
+
+  // free the memory associated with the FITS files
+  gfits_free_header (&header);
+  gfits_free_matrix (&matrix);
+  gfits_free_header (&theader);
+  gfits_free_table (&ftable);
 
   ALLOCATE (meanmags, MeanMag, Nrow);
@@ -83,6 +89,4 @@
   free (catID);
 
-  // free FITS table pieces...
-
   *nmeanmags = Nrow;
   return meanmags;
