Changeset db6bf74 for src


Ignore:
Timestamp:
Oct 15, 2009, 8:10:10 AM (16 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
c144ed2
Parents:
bbc338
Message:

Fixed two memory leaks.

  • FIX: if the element database could not be parsed, in LoadPeriodentafel() still one element would be allocated, Loading failure admonished and then not free'd. Fixed
  • FIX: the config was allocated in main not by a new, but fixed. In its constructor Malloc calls were present. Hence, the memory was not free'd. As fixed types are free'd first at the very end of the code. Hence before any MemoryUsageObserver::getUsedMemorySize() calls ... that's why 1614 bytes were always claimed as still allocated. Fixed.
  • valgrind does not admonish any leaks (however, some errors) anymore when molecuilder is started and immediately quitted.

Signed-off-by: Frederik Heber <heber@…>

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/builder.cpp

    rbbc338 rdb6bf74  
    5050using namespace std;
    5151
     52#include "analysis_correlation.hpp"
    5253#include "atom.hpp"
    5354#include "bond.hpp"
     
    13751376            cout << "\t-B xx xy xz yy yz zz\tBound atoms by domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl;
    13761377            cout << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl;
     1378            cout << "\t-C\tPair Correlation analysis." << endl;
    13771379            cout << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl;
    13781380            cout << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl;
     
    15751577              //argptr+=1;
    15761578              break;
     1579            case 'C':
     1580              if (ExitFlag == 0) ExitFlag = 1;
     1581              if ((argptr+1 >= argc) || (argv[argptr+1][0] == '-') || (argv[argptr+2][0] == '-')) {
     1582                ExitFlag = 255;
     1583                cerr << "Not enough or invalid arguments given for pair correlation analysis: -C <output> <bin output>" << endl;
     1584              } else {
     1585                SaveFlag = false;
     1586                ofstream output(argv[argptr]);
     1587                ofstream binoutput(argv[argptr+1]);
     1588                class Tesselation T;
     1589                const double radius = 5.;
     1590                LinkedCell LCList(mol, 2.*radius);
     1591                element *oxygen = periode->FindElement(8);
     1592                FindNonConvexBorder((ofstream *)&cout, mol, &LCList, radius, NULL);
     1593                CorrelationToSurfaceMap *surfacemap = CorrelationToSurface( (ofstream *)&cout, mol, oxygen, mol->TesselStruct, &LCList );
     1594                BinPairMap *binmap = BinData( (ofstream *)&cout, surfacemap, 0.5, 0., 0. );
     1595                OutputCorrelation ( &binoutput, binmap );
     1596                output.close();
     1597                binoutput.close();
     1598                argptr+=2;
     1599              }
     1600              break;
    15771601            case 'E':
    15781602              if (ExitFlag == 0) ExitFlag = 1;
     
    20432067  MoleculeListClass *molecules = new MoleculeListClass;  // list of all molecules
    20442068  molecule *mol = NULL;
    2045   config configuration;
     2069  config *configuration = new config;
    20462070  char choice;  // menu choice char
    20472071  Vector x,y,z,n;  // coordinates for absolute point in cell volume
     
    20532077
    20542078  // =========================== PARSE COMMAND LINE OPTIONS ====================================
    2055   j = ParseCommandLineOptions(argc, argv, molecules, periode, configuration, ConfigFileName);
     2079  j = ParseCommandLineOptions(argc, argv, molecules, periode, *configuration, ConfigFileName);
    20562080  switch(j) {
    20572081    case 255:  // something went wrong
     
    21352159
    21362160      case 'c': // edit each field of the configuration
    2137        configuration.Edit();
     2161       configuration->Edit();
    21382162       break;
    21392163
     
    21432167
    21442168      case 'g': // manipulate molecules
    2145         ManipulateMolecules(periode, molecules, &configuration);
     2169        ManipulateMolecules(periode, molecules, configuration);
    21462170        break;
    21472171
     
    21512175
    21522176      case 'm': // manipulate atoms
    2153         ManipulateAtoms(periode, molecules, &configuration);
     2177        ManipulateAtoms(periode, molecules, configuration);
    21542178        break;
    21552179
     
    21582182
    21592183      case 's': // save to config file
    2160         SaveConfig(ConfigFileName, &configuration, periode, molecules);
     2184        SaveConfig(ConfigFileName, configuration, periode, molecules);
    21612185        break;
    21622186
     
    21712195
    21722196  // save element data base
    2173   if (periode->StorePeriodentafel(configuration.databasepath)) //ElementsFileName
     2197  if (periode->StorePeriodentafel(configuration->databasepath)) //ElementsFileName
    21742198    cout << Verbose(0) << "Saving of elements.db successful." << endl;
    21752199  else
     
    21782202  delete(molecules); // also free's all molecules contained
    21792203  delete(periode);
     2204  delete(configuration);
    21802205
    21812206  cout << Verbose(0) <<  "Maximum of allocated memory: "
     
    21832208  cout << Verbose(0) <<  "Remaining non-freed memory: "
    21842209    << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl;
     2210  MemoryUsageObserver::purgeInstance();
    21852211
    21862212  return (0);
  • src/periodentafel.cpp

    rbbc338 rdb6bf74  
    215215        cout << "Could not parse element: ";
    216216        neues->Output((ofstream *)&cout);
     217        delete(neues);
    217218      }
    218219    }
Note: See TracChangeset for help on using the changeset viewer.