IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39439


Ignore:
Timestamp:
Mar 6, 2016, 8:58:07 PM (10 years ago)
Author:
eugene
Message:

plug memleaks

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

Legend:

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

    r39436 r39439  
    418418
    419419void relastro_client_free ();
     420void relastro_free ();
    420421
    421422GSCRegion    *find_regions        PROTO((Image *image, off_t Nimage, int *Nregions, GSCRegion *fullregion));
     
    439440void          initImageBins       PROTO((Catalog *catalog, int Ncatalog, int FULLINIT));
    440441void          initImages          PROTO((Image *input, off_t *line_number, off_t N));
     442void          freeImages          PROTO(());
    441443void          initMosaicBins      PROTO((Catalog *catalog, int Ncatalog));
    442444void          initMosaicGrid      PROTO((Image *image, off_t Nimage));
     
    554556Mosaic *getmosaics (off_t *N);
    555557void initMosaics (Image *image, off_t Nimage);
     558void freeMosaics ();
    556559StarData *getMosaicRaw (Catalog *catalog, int Ncatalog, off_t mos, off_t *Nstars);
    557560StarData *getMosaicRef (Catalog *catalog, int Ncatalog, off_t mos, off_t *Nstars);
     
    590593
    591594int initStarMaps ();
     595void freeStarMaps ();
    592596int updateStarMaps(Catalog *catalog);
    593597int createStarMapPoints();
     
    684688AstromOffsetTable *get_astrom_table ();
    685689void put_astrom_table (AstromOffsetTable *myTable);
     690void free_astrom_table ();
    686691
    687692int fit_map (AstromOffsetMap *map, StarData *raw, StarData *ref, int Npts);
  • branches/eam_branches/ohana.20160226/src/relastro/src/BootstrapOps.c

    r39364 r39439  
    9898      myAbort ("invalid option");
    9999  }
     100  free (values);
    100101
    101102  return TRUE;
  • branches/eam_branches/ohana.20160226/src/relastro/src/BrightCatalog.c

    r39413 r39439  
    829829int BrightCatalogSplitFree (CatalogSplitter *catalogs) {
    830830
    831   free (catalogs->catIDs);
    832   free (catalogs->NAVERAGE);
    833   free (catalogs->NMEASURE);
    834   free (catalogs->index);
    835   free (catalogs);
     831# if (0)
     832  int i;
     833
     834  for (i = 0; i < catalogs->NCATALOG; i++) {
     835    FREE (catalogs->catalog[i].average);
     836    FREE (catalogs->catalog[i].secfilt);
     837    FREE (catalogs->catalog[i].measureT);
     838  }
     839  FREE (catalogs->catalog);
     840# endif
     841
     842  FREE (catalogs->catIDs);
     843  FREE (catalogs->NAVERAGE);
     844  FREE (catalogs->NMEASURE);
     845  FREE (catalogs->index);
     846  FREE (catalogs);
    836847  return TRUE;
    837848}
  • branches/eam_branches/ohana.20160226/src/relastro/src/FitAstromOps.c

    r39375 r39439  
    297297    median = x[(int)(0.5*Npoints)];
    298298  }
     299  free (x);
    299300
    300301  return median;
  • branches/eam_branches/ohana.20160226/src/relastro/src/ImageOps.c

    r39432 r39439  
    119119  }
    120120# endif
     121}
     122
     123void freeImages () {
     124
     125  FREE (LineNumber);
     126
     127# if USE_IMAGE_ID
     128  FREE (imageIDs);
     129  FREE (imageIdx);
     130  FREE (imageSeq);
     131# else
     132  FREE (start);
     133  FREE (stop);
     134# endif
     135
     136  free_astrom_table();
    121137}
    122138
     
    196212
    197213  for (i = 0; i < Ncatalog; i++) {
    198     free (MeasureToImage[i]);
    199   }
    200   free (MeasureToImage);
     214    FREE (MeasureToImage[i]);
     215  }
     216  FREE (MeasureToImage);
    201217  for (i = 0; i < Nimage; i++) {
    202     if (ImageToCatalog[i]) { free (ImageToCatalog[i]); }
    203     if (ImageToMeasure[i]) { free (ImageToMeasure[i]); }
    204   }
    205   free (ImageToCatalog);
    206   free (ImageToMeasure);
    207   free (N_onImage);
    208   free (N_ONIMAGE);
     218    FREE (ImageToCatalog[i]);
     219    FREE (ImageToMeasure[i]);
     220    FREE (catlist[i]);
     221  }
     222  FREE (Ncatlist);
     223  FREE (NCATLIST);
     224  FREE (catlist);
     225
     226  FREE (ImageToCatalog);
     227  FREE (ImageToMeasure);
     228  FREE (N_onImage);
     229  FREE (N_ONIMAGE);
    209230}
    210231
     
    239260      name = GetPhotcodeNamebyCode (image[i].photcode);
    240261      int showExample = (Nfew < 30);
    241       if (showExample) fprintf (stderr, "image "OFF_T_FMT" (%d, %s) has "OFF_T_FMT" of %d measures (%s, %s) ",  i,  image[i].imageID, image[i].name, N_onImage[i], image[i].nstar,
    242                ohana_sec_to_date(image[i].tzero), name);
     262      if (showExample) {
     263        char *myDate = ohana_sec_to_date(image[i].tzero);
     264        fprintf (stderr, "image "OFF_T_FMT" (%d, %s) has "OFF_T_FMT" of %d measures (%s, %s) ",  i,  image[i].imageID, image[i].name, N_onImage[i], image[i].nstar, myDate, name);
     265        free (myDate);
     266      }
    243267      if (N_onImage[i] < 20) {
    244268        if (showExample) fprintf (stderr, "*");
  • branches/eam_branches/ohana.20160226/src/relastro/src/ImageTable.c

    r38441 r39439  
    3333  }
    3434
     35  // gfits_db_free (&db);
     36  gfits_free_header (&db.header);
     37  gfits_free_matrix (&db.matrix);
     38  gfits_free_header (&db.theader);
     39  free (db.filename);
     40
    3541  *nimage = Nimage;
    3642  return image;
     
    6167  dvo_image_unlock (&db);
    6268
     69  gfits_db_free (&db);
     70
    6371  return TRUE;
    6472}
  • branches/eam_branches/ohana.20160226/src/relastro/src/MosaicOps.c

    r39411 r39439  
    33// array of mosaic definition structures
    44static off_t   Nmosaic;
    5 static Mosaic *mosaic;
     5static Mosaic *mosaic = NULL;
    66
    77// list of all images associated with a mosaic
     
    185185}
    186186
     187void freeMosaics () {
     188
     189  off_t i;
     190
     191  if (!mosaic) return;
     192
     193  for (i = 0; i < Nmosaic; i++) {
     194    FREE (mosaic_own_images[i]);
     195  }
     196
     197  FREE (mosaic);
     198  FREE (Nmosaic_own_images);
     199  FREE (Amosaic_own_images);
     200  FREE (mosaic_own_images);
     201  FREE (mosaic_for_images);
     202}
     203
    187204// return StarData values for detections in the specified image, converting coordinates from the
    188205// chip positions: X,Y -> L,M -> P,Q -> R,D
     
    325342    }
    326343   
     344    free (addMosaic);
     345
    327346    host->Nimage += Nadd;
    328347  }
     348  free (mosaicUsed);
     349
    329350  return TRUE;
    330351}
  • branches/eam_branches/ohana.20160226/src/relastro/src/StarMaps.c

    r38986 r39439  
    2525} StarMap;
    2626
    27 static StarMap     *starmap;       
     27static StarMap *starmap = NULL;
    2828// static int         Nstarmap;  -- is it always == Nimages?
    2929
     
    5555}
    5656
     57void freeStarMaps () {
     58
     59  off_t i, Nimages;
     60
     61  getimages(&Nimages, NULL);
     62
     63  for (i = 0; i < Nimages; i++) {
     64    FREE (starmap[i].points);
     65    FREE (starmap[i].stars);
     66  }
     67
     68  FREE (starmap);
     69  return;
     70}
     71
    5772int updateStarMaps(Catalog *catalog) {
    5873
  • branches/eam_branches/ohana.20160226/src/relastro/src/args.c

    r39436 r39439  
    380380      snprintf (PHOTCODE_SKIP_LIST, Ntotal, "%s,%s", SuperCOSMOS_SKIP, RawSkip);
    381381      free (RawSkip);
    382       free (SuperCOSMOS_SKIP);
    383382    } else {
    384383      PHOTCODE_SKIP_LIST = RawSkip;
     
    386385    remove_argument (N, &argc, argv);
    387386  }
     387  free (SuperCOSMOS_SKIP);
    388388
    389389  VERBOSE = VERBOSE2 = FALSE;
     
    570570  if (argc != 1) usage ();
    571571  return TRUE;
     572}
     573
     574void relastro_free () {
     575  FREE (REGION_FILE);
     576  FREE (IMAGE_TABLE);
     577  FREE (LoopWeight2MASSstr);
     578  FREE (LoopWeightTychostr);
     579
     580  FREE (PHOTCODE_SKIP_LIST);
     581  FREE (PHOTCODE_KEEP_LIST);
     582  FREE (PHOTCODE_RESET_LIST);
     583  FREE (DCR_RED_COLOR_POS);
     584  FREE (DCR_RED_COLOR_NEG);
     585  FREE (DCR_BLUE_COLOR_POS);
     586  FREE (DCR_BLUE_COLOR_NEG);
     587
     588  FREE (PHOTCODE_A_LIST);
     589  FREE (PHOTCODE_B_LIST);
     590  FREE (HIGH_SPEED_DIR);
     591  FREE (BCATALOG);
     592  FREE (HOSTDIR);
    572593}
    573594
  • branches/eam_branches/ohana.20160226/src/relastro/src/launch_region_hosts.c

    r39389 r39439  
    161161    fprintf (stderr, "command: %s\n", command);
    162162   
    163     if (PARALLEL_REGIONS_MANUAL) continue;
     163    if (PARALLEL_REGIONS_MANUAL) {
     164      free (command);
     165      continue;
     166    }
    164167
    165168    // launch the job, then wait for it to be done loading catalogs.  force the remote
     
    180183    check_sync_file (syncfile, 1);
    181184    free (syncfile);
     185
     186    free (command);
    182187  }
    183188
  • branches/eam_branches/ohana.20160226/src/relastro/src/load_catalogs.c

    r39436 r39439  
    229229    fprintf (stderr, "command: %s\n", command);
    230230
    231     if (PARALLEL_MANUAL) continue;
     231    if (PARALLEL_MANUAL) {
     232      free (command);
     233      continue;
     234    }
    232235
    233236    if (PARALLEL_SERIAL) {
     
    247250      table->hosts[i].pid = pid; // save for future reference
    248251    }
     252    free (command);
    249253  }
    250254
     
    294298  }
    295299
     300  FreeHostTable (table);
     301
    296302  Catalog *catalog = catalogs->catalog;
    297303  *Ncatalog = catalogs->Ncatalog;
     304
     305  // need to free the place-holder catalogs:
     306  for (i = catalogs->Ncatalog; i < catalogs->NCATALOG; i++) {
     307    free (catalogs->catalog[i].average);
     308    free (catalogs->catalog[i].measureT);
     309    free (catalogs->catalog[i].secfilt);
     310  }
    298311
    299312  int Nmeasure = 0;
  • branches/eam_branches/ohana.20160226/src/relastro/src/load_images.c

    r38986 r39439  
    102102}
    103103
     104void free_astrom_table () {
     105  if (!table) return;
     106  AstromOffsetTableFree (table);
     107  free (table);
     108}
  • branches/eam_branches/ohana.20160226/src/relastro/src/relastro.c

    r39382 r39439  
    77  initialize (argc, argv);
    88
    9   SkyTable *sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    10   SkyTableSetFilenames (sky, CATDIR, "cpt");
    11   SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch);
     9  SkyTable *sky = NULL;
     10  SkyList *skylist = NULL;
     11
     12  if ((RELASTRO_OP != OP_PARALLEL_IMAGES) && (RELASTRO_OP != OP_PARALLEL_REGIONS)) {
     13    sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
     14    SkyTableSetFilenames (sky, CATDIR, "cpt");
     15    skylist = SkyListByPatch (sky, -1, &UserPatch);
     16  }
    1217
    1318  switch (RELASTRO_OP) {
     
    1520      /* the object analysis is a separate process iterating over catalogs */
    1621      relastro_objects (skylist, 0, NULL);
     22      ohana_memcheck (VERBOSE);
     23      ohana_memdump (VERBOSE);
    1724      exit (0);
    1825
     
    3340    case OP_IMAGES:
    3441      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);
    3556      exit (0);
    3657
     
    5576      // iterate over catalogs to make detection coordinates consistant
    5677      UpdateObjectOffsets (skylist, 0, NULL);
     78      ohana_memcheck (VERBOSE);
     79      ohana_memdump (VERBOSE);
    5780      exit (0);
    5881
  • branches/eam_branches/ohana.20160226/src/relastro/src/relastro_images.c

    r39434 r39439  
    9898  }
    9999
    100   if (!UPDATE) exit (0);
     100  if (!UPDATE) {
     101    freeStarMaps();
     102    gfits_db_free (&db);
     103    ohana_memcheck (VERBOSE);
     104    ohana_memdump (VERBOSE);
     105    exit (0);
     106  }
    101107
    102108  // free the image / measurement pointers
    103   freeImageBins (1);
     109  freeImageBins (Ncatalog);
     110  for (i = 0; i < Ncatalog; i++) {
     111    dvo_catalog_free (&catalog[i]);
     112  }
     113  free (catalog);
     114  freeMosaics ();
    104115
    105116  // If we did NOT use all images, then we applied the measured corrections to a subset of
     
    110121    reload_images (&db);
    111122  }
     123  freeStarMaps();
    112124   
    113125  if (PARALLEL) {
     
    121133    }
    122134    dvo_image_unlock (&db);
     135    gfits_db_free (&db);
     136    freeImages();
    123137  }
    124138
     
    146160    }
    147161    dvo_image_unlock (&db);
     162    gfits_db_free (&db);
     163    freeImages();
    148164  }
    149165
    150   exit (0);
     166  return TRUE;
    151167}
  • branches/eam_branches/ohana.20160226/src/relastro/src/relastro_parallel_images.c

    r39432 r39439  
    181181  LOGRTIME("share image pos loop %d on %s, host %d: %f sec\n", -1, myHostName, REGION_HOST_ID, dtime);
    182182
     183  // free the image / measurement pointers
     184  freeImageBins (Ncatalog);
     185  for (i = 0; i < Ncatalog; i++) {
     186    dvo_catalog_free (&catalog[i]);
     187  }
     188  free (catalog);
     189  freeMosaics ();
     190
     191  freeStarMaps();
     192
     193  freeImages();
     194  free (image);
     195
     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 
     207  FreeRegionHostTable (regionHosts);
     208
     209  ohana_memcheck (VERBOSE);
     210  ohana_memdump (VERBOSE);
    183211  exit (0);
    184212}
  • branches/eam_branches/ohana.20160226/src/relastro/src/relastro_parallel_regions.c

    r38441 r39439  
    8383  }
    8484
     85// testjump:
     86
    8587  MARKTIME ("finished relastro -parallel-regions: %f sec total\n", dtime);
     88 
     89  gfits_db_free (&db);
     90  freeImages();
     91  freeMosaics ();
     92
     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 
     104  FreeRegionHostTable (regionHosts);
     105
     106  ohana_memcheck (VERBOSE);
     107  ohana_memdump (VERBOSE);
    86108
    87109  exit (0);
  • branches/eam_branches/ohana.20160226/src/relastro/src/share_images_pos.c

    r39435 r39439  
    141141
    142142    AstromOffsetTableFree(table);
     143    free (table);
    143144    LOGRTIME("image_maps_free host %d loop %d on %s, host %d: %f sec\n", i, nloop, myHostName, REGION_HOST_ID, dtime);
    144145  }
Note: See TracChangeset for help on using the changeset viewer.