[Coin-discuss] more memory problems.

Paul Pacheco paul.pacheco at wavecode.com
Mon Oct 6 15:47:13 EDT 2003


Another memory leak.

==20965== 8 bytes in 1 blocks are definitely lost in loss record 1 of 11
==20965==    at 0x400297D5: __builtin_new (in /usr/lib/valgrind/vgskin_memcheck.so)
==20965==    by 0x40029840: operator new(unsigned) (in /usr/lib/valgrind/vgskin_memcheck.so)
==20965==    by 0x809B140: BCP_pvm_environment::start_processes(BCP_string const&, int, bool) (BCP_message_pvm.cpp:376)
==20965==    by 0x808F6DF: BCP_tm_start_processes(BCP_tm_prob&) (BCP_tm_msgproc.cpp:54)


This is where the new is performed:



BCP_proc_array*
BCP_pvm_environment::start_processes(const BCP_string& exe,
				     const int proc_num,
				     const bool debug) {
   BCP_vec<BCP_proc_id*> procs;
   procs.reserve(proc_num);

   int flag = debug ? PvmTaskDebug : 0;
   int* pids = new int[proc_num];
   char* exe_name;
   char** exe_args;
   BCP_pvm_split_exe(exe, exe_name, exe_args);
   pvm_spawn(exe_name, exe_args, flag, 0, proc_num, pids);
   delete[] exe_name;
   if (exe_args != 0) {
      while (*exe_args != 0) {
	 delete[] *exe_args;
	 ++exe_args;
      }
      delete[] exe_args;
   }
   for (int i = 0; i != proc_num; ++i)
      check_error(pids[i], "start_processes() - spawn");
   for (int i = 0; i != proc_num; ++i)
      procs.push_back(new BCP_pvm_id(pids[i]));                                         # this new is never being deleted
   delete[] pids;
   BCP_proc_array* pa = new BCP_proc_array;
   pa->add_procs(procs.begin(), procs.end());
   return pa;
}




That new is never deleted. the actual BCP_proc_array is deleted by  the destructor of the class BCP_slave_processes. However, the object BCP_pvm_id is never being deleted.
I didn't post a patch because I don't know where this should be deleted. My guess is in the BCP_slave_process destructor, or in the BCP_tm_prob destructor.




More information about the Coin-discuss mailing list