IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39442


Ignore:
Timestamp:
Mar 8, 2016, 11:27:24 AM (10 years ago)
Author:
eugene
Message:

plug all memory leaks; free all memory at the end

Location:
branches/eam_branches/ohana.20160226/src/relastro
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20160226/src/relastro/include/relastro.h

    r39439 r39442  
    417417int SetSignals (void);
    418418
    419 void relastro_client_free ();
    420 void relastro_free ();
     419void relastro_free (SkyTable *sky, SkyList *skylist);
     420void relastro_client_free (SkyTable *sky, SkyList *skylist);
    421421
    422422GSCRegion    *find_regions        PROTO((Image *image, off_t Nimage, int *Nregions, GSCRegion *fullregion));
     
    660660int indexCatalogs (Catalog *catalog, int Ncatalog);
    661661int catID_and_objID_to_seq (unsigned int catID, unsigned int objID, int *catSeq, off_t *objSeq);
     662void freeCatalogIndexes (int Ncatalog);
    662663
    663664int markObjects (Catalog *catalog, int Ncatalog);
  • branches/eam_branches/ohana.20160226/src/relastro/src/ImageOps.c

    r39439 r39442  
    99// if we read only a subset of the rows from the Image FITS, LineNumber tells us to which row
    1010// each image belongs
    11 static off_t       *LineNumber; // match of subset to full image table
    12 
    13 static off_t        *N_onImage;   // number of measurements on image
    14 static off_t        *N_ONIMAGE;   // allocated number of measurements on image   
    15 
    16 static int          *Ncatlist;  // catalogs associated with each image
    17 static int          *NCATLIST;  // catalogs associated with each image
    18 static int         **catlist;  // catalogs associated with each image
    19 
    20 static IDX_T       **MeasureToImage;     // link from catalog,measure to image
    21 static IDX_T       **ImageToCatalog;   // catalog which supplied measurement on image
    22 static IDX_T       **ImageToMeasure;   // measure reference for measurement on image
     11static off_t       *LineNumber = NULL; // match of subset to full image table
     12
     13static off_t        *N_onImage = NULL;   // number of measurements on image
     14static off_t        *N_ONIMAGE = NULL;   // allocated number of measurements on image   
     15
     16static int          *Ncatlist = NULL;  // catalogs associated with each image
     17static int          *NCATLIST = NULL;  // catalogs associated with each image
     18static int         **catlist  = NULL;  // catalogs associated with each image
     19
     20static IDX_T       **MeasureToImage = NULL;     // link from catalog,measure to image
     21static IDX_T       **ImageToCatalog = NULL;   // catalog which supplied measurement on image
     22static IDX_T       **ImageToMeasure = NULL;   // measure reference for measurement on image
    2323
    2424// if we search by image ID, we sort (imageIDs, imageIdx) by imageIDs to get a sorted
     
    2626
    2727# if USE_IMAGE_ID
    28 static off_t        *imageIDs; // list of all image IDs
    29 static off_t        *imageIdx; // list of index for image IDs
     28static off_t        *imageIDs = NULL; // list of all image IDs
     29static off_t        *imageIdx = NULL; // list of index for image IDs
    3030
    3131// as an alternative, we generate imageSeq, which directly maps imageID -> seq
    32 static off_t        *imageSeq; // list of index for image IDs
     32static off_t        *imageSeq = NULL; // list of index for image IDs
    3333
    3434// MAX_ID requires 512M to store the image index
     
    218218    FREE (ImageToCatalog[i]);
    219219    FREE (ImageToMeasure[i]);
    220     FREE (catlist[i]);
     220    if (catlist) { FREE (catlist[i]); }
    221221  }
    222222  FREE (Ncatlist);
    223223  FREE (NCATLIST);
    224224  FREE (catlist);
     225  Ncatlist = NULL;
     226  NCATLIST = NULL;
     227  catlist  = NULL;
    225228
    226229  FREE (ImageToCatalog);
  • branches/eam_branches/ohana.20160226/src/relastro/src/UpdateObjectOffsets.c

    r39171 r39442  
    6262    // uses MeasureTiny values, but will also update Measure values when populated
    6363    // if Galaxy Motion Model correction is active, do not apply at this last stage
    64     UpdateObjects (&catalog, 1, FALSE);
     64    UpdateObjects (&catalog, 1, -1);
    6565
    6666    free_tiny_values(&catalog);
     
    218218    fprintf (stderr, "command: %s\n", command);
    219219
    220     if (PARALLEL_MANUAL) continue;
     220    if (PARALLEL_MANUAL) {
     221      free (command);
     222      continue;
     223    }
    221224
    222225    if (PARALLEL_SERIAL) {
     
    236239      group->hosts[i][0].pid = pid; // save for future reference
    237240    }
     241    free (command);
    238242  }
    239243
     
    338342    fprintf (stderr, "command: %s\n", command);
    339343
    340     if (PARALLEL_MANUAL) continue;
     344    if (PARALLEL_MANUAL) {
     345      free (command);
     346      continue;
     347    }
    341348
    342349    if (PARALLEL_SERIAL) {
     
    356363      table->hosts[i].pid = pid; // save for future reference
    357364    }
     365    free (command);
    358366  }
    359367
     
    366374  }
    367375
     376  FreeHostTable (table);
     377
    368378  return TRUE;
    369379}     
  • branches/eam_branches/ohana.20160226/src/relastro/src/args.c

    r39439 r39442  
    572572}
    573573
    574 void relastro_free () {
     574void relastro_free (SkyTable *sky, SkyList *skylist) {
    575575  FREE (REGION_FILE);
    576576  FREE (IMAGE_TABLE);
     
    591591  FREE (BCATALOG);
    592592  FREE (HOSTDIR);
     593
     594  // these are set in initialize
     595  FREE(photcodesKeep);
     596  FREE(photcodesSkip); 
     597  FREE(photcodesReset);
     598  FREE(photcodesGroupA);
     599  FREE(photcodesGroupB);
     600 
     601  SkyTableFree (sky);
     602  SkyListFree(skylist);
     603  FreePhotcodeTable();
     604 
     605  ohana_memcheck (VERBOSE);
     606  ohana_memdump (VERBOSE);
    593607}
    594608
     
    951965}
    952966
    953 void relastro_client_free () {
     967void relastro_client_free (SkyTable *sky, SkyList *skylist) {
    954968  FREE (PHOTCODE_SKIP_LIST);
    955969  FREE (PHOTCODE_KEEP_LIST);
     
    965979  FREE(BCATALOG);
    966980  FREE (HOSTDIR);
     981
     982  // these are set in initialize
     983  FREE(photcodesKeep);
     984  FREE(photcodesSkip); 
     985  FREE(photcodesReset);
     986  FREE(photcodesGroupA);
     987  FREE(photcodesGroupB);
     988 
     989  SkyTableFree (sky);
     990  SkyListFree(skylist);
     991  FreePhotcodeTable();
     992 
     993  ohana_memcheck (VERBOSE);
     994  ohana_memdump (VERBOSE);
    967995}
    968996
  • branches/eam_branches/ohana.20160226/src/relastro/src/indexCatalogs.c

    r39412 r39442  
    5151}
    5252
     53void freeCatalogIndexes (int Ncatalog) {
     54  int i;
     55
     56  for (i = 0; i < Ncatalog; i++) {
     57    free (objIDseq[i]);
     58  }
     59  free (objIDmax);
     60  free (objIDseq);
     61  free (catIDseq);
     62}
     63
    5364int catID_and_objID_to_seq (unsigned int catID, unsigned int objID, int *catSeq, off_t *objSeq) {
    5465
  • branches/eam_branches/ohana.20160226/src/relastro/src/initialize.c

    r37807 r39442  
    22
    33void initialize (int argc, char **argv) {
     4
     5  photcodesKeep   = NULL;
     6  photcodesSkip   = NULL;
     7  photcodesReset  = NULL;
     8  photcodesGroupA = NULL;
     9  photcodesGroupB = NULL;
    410
    511  ConfigInit (&argc, argv);
  • branches/eam_branches/ohana.20160226/src/relastro/src/relastro.c

    r39439 r39442  
    2020      /* the object analysis is a separate process iterating over catalogs */
    2121      relastro_objects (skylist, 0, NULL);
    22       ohana_memcheck (VERBOSE);
    23       ohana_memdump (VERBOSE);
    24       exit (0);
    25 
    26     case OP_HIGH_SPEED:
    27       /* high-speed is a 2pt cross-correlation process for linking moving objects (high PM) */
    28       high_speed_catalogs (sky, skylist, 0, NULL);
    29       exit (0);
    30 
    31     case OP_HPM:
    32       hpm_catalogs (sky, skylist, 0, NULL);
    33       exit (0);
    34 
    35     case OP_MERGE_SOURCE:
    36       /* a special method to manually merge unlinked detections of sources togther (not parallel) */
    37       relastro_merge_source (sky);
     22      relastro_free (sky, skylist);
    3823      exit (0);
    3924
    4025    case OP_IMAGES:
    4126      relastro_images (skylist);
    42 
    43       relastro_free ();
    44       FREE(photcodesKeep);
    45       FREE(photcodesSkip); 
    46       FREE(photcodesReset);
    47       FREE(photcodesGroupA);
    48       FREE(photcodesGroupB);
    49 
    50       SkyTableFree (sky);
    51       SkyListFree(skylist);
    52       FreePhotcodeTable();
    53 
    54       ohana_memcheck (VERBOSE);
    55       ohana_memdump (VERBOSE);
     27      relastro_free (sky, skylist);
    5628      exit (0);
    5729
    58     case OP_UPDATE_OFFSETS:
     30    case OP_UPDATE_OFFSETS: {
     31      FITS_DB db;
    5932      if (!PARALLEL) {
    60         FITS_DB db;
    6133     
    6234        set_db (&db);
     
    7648      // iterate over catalogs to make detection coordinates consistant
    7749      UpdateObjectOffsets (skylist, 0, NULL);
    78       ohana_memcheck (VERBOSE);
    79       ohana_memdump (VERBOSE);
     50
     51      if (!PARALLEL) {
     52        gfits_db_free (&db);
     53        freeImages();
     54        freeMosaics ();
     55      }
     56
     57      relastro_free (sky, skylist);
    8058      exit (0);
     59    }
    8160
    8261    case OP_PARALLEL_REGIONS:
     
    9069      exit (0);
    9170
     71    case OP_HIGH_SPEED:
     72      /* high-speed is a 2pt cross-correlation process for linking moving objects (high PM) */
     73      high_speed_catalogs (sky, skylist, 0, NULL);
     74      exit (0);
     75
     76    case OP_HPM:
     77      hpm_catalogs (sky, skylist, 0, NULL);
     78      exit (0);
     79
     80    case OP_MERGE_SOURCE:
     81      /* a special method to manually merge unlinked detections of sources togther (not parallel) */
     82      relastro_merge_source (sky);
     83      exit (0);
     84
    9285    default:
    9386      fprintf (stderr, "impossible!\n");
  • branches/eam_branches/ohana.20160226/src/relastro/src/relastro_client.c

    r39396 r39442  
    5555      }
    5656
    57       SkyTableFree (sky);
    58       SkyListFree(skylist);
    59       FreePhotcodeTable();
    60 
    6157      int i;
    6258      for (i = 0; i < Ncatalog; i++) {
     
    6662      BrightCatalogFree(bcatalog);
    6763
    68       relastro_client_free ();
    69       FREE(photcodesKeep);
    70       FREE(photcodesSkip); 
    71       FREE(photcodesReset);
    72       FREE(photcodesGroupA);
    73       FREE(photcodesGroupB);
    74 
    75       ohana_memcheck (TRUE);
    76       ohana_memdump (TRUE);
     64      relastro_client_free (sky, skylist);
    7765      break;
    7866    }
     
    8169      // USAGE: relastro_client -update-objects
    8270      relastro_objects (skylist, HOST_ID, HOSTDIR);
    83       break;
    84     }
    85 
    86     case OP_HIGH_SPEED: {
    87       // USAGE: relastro_client -high-speed
    88       high_speed_catalogs (sky, skylist, HOST_ID, HOSTDIR);
    89       break;
    90     }
    91 
    92     case OP_HPM: {
    93       // USAGE: relastro_client -high-speed
    94       hpm_catalogs (sky, skylist, HOST_ID, HOSTDIR);
     71      relastro_client_free (sky, skylist);
    9572      break;
    9673    }
     
    11289      /* load regions and images based on specified sky patch (default depth) */
    11390      load_images (&db, skylist, FALSE, USE_ALL_IMAGES);
    114      
    115       // I can free the database after I have loaded the images...
    116 
    117       // // load the image subset table from the specified location
    118       // off_t Nimage;
    119       // ImageSubset *image = ImageSubsetLoad (IMAGES, &Nimage);
    120       // if (!image) {
    121       //          fprintf (stderr, "ERROR loading image subset %s\n", CATDIR);
    122       //          exit (2);
    123       // }
    124       //
    125       // // save the available image information in the static array in ImageOps.c
    126       // initImagesSubset (image, NULL, Nimage);
    127       //
    128       // // load the flat-field correction table from CATDIR
    129       // char flatcorrFile[1024];
    130       // snprintf (flatcorrFile, 1024, "%s/flatcorr.fits", CATDIR);
    131       // FlatCorrectionTable *flatcorr = FlatCorrectionLoad (flatcorrFile, VERBOSE);
    13291
    13392      UpdateObjectOffsets (skylist, HOST_ID, HOSTDIR);
    13493     
     94      gfits_db_free (&db);
     95      freeImages();
     96      freeMosaics ();
     97
     98      relastro_client_free (sky, skylist);
     99      break;
     100    }
     101
     102    case OP_HIGH_SPEED: {
     103      // USAGE: relastro_client -high-speed
     104      high_speed_catalogs (sky, skylist, HOST_ID, HOSTDIR);
     105      break;
     106    }
     107
     108    case OP_HPM: {
     109      // USAGE: relastro_client -high-speed
     110      hpm_catalogs (sky, skylist, HOST_ID, HOSTDIR);
    135111      break;
    136112    }
  • branches/eam_branches/ohana.20160226/src/relastro/src/relastro_objects.c

    r39375 r39442  
    8484    populate_tiny_values(&catalog, DVO_TV_MEASURE);
    8585
    86     UpdateObjects (&catalog, 1, 0);
     86    // the 3rd argument (-1) is the loop number for re-weighting 2MASS and Tycho. -1 is a special value meaning "ignore"
     87    // we do NOT want to apply special weights to 2MASS and/or Tycho when calculating object final motions.
     88    UpdateObjects (&catalog, 1, -1);
    8789
    8890    free_tiny_values(&catalog);
     
    215217      table->hosts[i].pid = pid; // save for future reference
    216218    }
     219    free (command);
    217220  }
    218221
     
    224227    HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);
    225228  }
     229  FreeHostTable (table);
    226230
    227231  return TRUE;
  • branches/eam_branches/ohana.20160226/src/relastro/src/relastro_parallel_images.c

    r39439 r39442  
    1616
    1717  INITTIME;
     18
     19  // over-ride user selection here: this program does not set the final object
     20  // astrometry.  since it only sets the image parameters it should not use pm or par
     21  FIT_MODE = FIT_AVERAGE;
    1822
    1923  client_logger_init (CATDIR);
     
    187191  }
    188192  free (catalog);
     193  freeCatalogIndexes(Ncatalog);
     194
    189195  freeMosaics ();
    190196
     
    194200  free (image);
    195201
    196   relastro_free ();
    197   FREE(photcodesKeep);
    198   FREE(photcodesSkip); 
    199   FREE(photcodesReset);
    200   FREE(photcodesGroupA);
    201   FREE(photcodesGroupB);
    202  
    203   SkyTableFree (sky);
    204   SkyListFree(skylist);
    205   FreePhotcodeTable();
    206  
    207202  FreeRegionHostTable (regionHosts);
    208 
    209   ohana_memcheck (VERBOSE);
    210   ohana_memdump (VERBOSE);
     203  relastro_free (sky, skylist);
     204
    211205  exit (0);
    212206}
  • branches/eam_branches/ohana.20160226/src/relastro/src/relastro_parallel_regions.c

    r39439 r39442  
    9191  freeMosaics ();
    9292
    93   relastro_free ();
    94   FREE(photcodesKeep);
    95   FREE(photcodesSkip); 
    96   FREE(photcodesReset);
    97   FREE(photcodesGroupA);
    98   FREE(photcodesGroupB);
    99  
    100   SkyTableFree (sky);
    101   SkyListFree(skylist);
    102   FreePhotcodeTable();
    103  
    10493  FreeRegionHostTable (regionHosts);
    105 
    106   ohana_memcheck (VERBOSE);
    107   ohana_memdump (VERBOSE);
     94  relastro_free (sky, skylist);
    10895
    10996  exit (0);
Note: See TracChangeset for help on using the changeset viewer.