We encounter a momory leak in VB 4.5 for C++.
It occurs in the all_instances_descs(...) call on the LocationService, and
it is the returned sequence that leaks.
Being a DesSeq_var I would think it should be cleaned up when leaving scope.
To me it looks like a bug in VB, but maybe we are doing it wrong...
Below is a small test program showing the leak.
Any help will be _greatly_ appreciated!
-Bjarte
int main(int argc, char** argv)
{
CORBA::ORB_var orb;
ObjLocation::Agent_var the_agent;
try {
orb = CORBA::ORB_init(argc, argv);
CORBA::Object_var obj =
orb->resolve_initial_references("LocationService");
if (CORBA::is_nil(obj) ) {
cout << "Unable to locate initial LocationService" << endl;
return 0;
}
the_agent = ObjLocation::Agent::_narrow(obj);
} catch (...) {};
for (int z=0; z < 1000; z++) {
cout << "Run: " << z << endl;
try {
// -------------- All repository IDs -----------
// Find and display all Repository Ids
ObjLocation::RepositoryIdSeq_var repIds =
the_agent->all_repository_ids();
cout << "Located " << repIds->length() << " Repository Ids" <<
endl;
// Find all Object Descriptors for each Repository Id
//##########################################################################
###
// THIS LOOP LEAKS MEMORY LIKE CRAZY
// MUST BE AN ERROR INTERNAL TO all_instances_descs OR
ObjLocation::DescSeq_var
//##########################################################################
###
for (CORBA::ULong i=0; i < repIds->length(); i++) {
ObjLocation::DescSeq_var descriptors =
the_agent->all_instances_descs(repIds[i]);
cout << endl;
cout << "Located " << descriptors->length() << " objects for "
<< (const char*) (repIds[i]) << " (Repository Id #" <<
(i+1)
<< "):" << endl;
}
} catch (const CORBA::Exception& e) {
cout << "CORBA Exception during execution of find_all: " << e <<
endl;
continue;
}
}
return 1;
}