Author Topic: Destructing COM objects and freeing memory?  (Read 1978 times)

chrvi

  • EA User
  • **
  • Posts: 75
  • Karma: +0/-0
  • There are so many hidden features...
    • View Profile
Destructing COM objects and freeing memory?
« on: May 29, 2007, 01:37:51 am »
Hi there,

once again the question of memory lacks when using automation and Java...

I've just installed the new Enterprise Architect (6.5.805)and started using the eaapi.jar and SSJavaCOM.dll files.

I have a package and I wish to add subpackages as follows:

Collection<Package> subPackages;
subPackages = myPackage.GetPackages();
for (...) {
 newPackage = subPackages.AddNew("Package Name","foo");
    // by the way - what is the second parameter good for?
 newPackage.Update();
 subPackages.Refresh();
}

Now I'm going to process another package and add subpackeges to it in the same way, so I'd like to destroy the existing subPackages COM object since I won't need it any more (EA project has already been updated with the inserted subPackages in the for cycle above) and free the consumed memory.
I tried this:

subPackages.destroy();
subPackages = null;
repository.Compact();

The subPackages COM object was probably destroyed succsessfully, its number set to 0, then I set subpackages to null and called repository.Compact() but the memory usage didn't change at all.
I'm quite desperate 'cause my large model will consume all the memory resources unless I find out how to explicitely free memory at desired places in my code.
« Last Edit: May 31, 2007, 03:34:22 am by chrvi »
Radek