Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: chrvi on October 03, 2007, 09:45:20 am

Title: How to force EA process to finish?
Post by: chrvi on October 03, 2007, 09:45:20 am
Hello,

I wonder if anybody knows how to force EA process to quit before my Java application finishes as well.

Although I call
   repository.CloseFile();
   repository.Compact();
the EA process is still alive and doesn't quit until my Java application also finishes.

Don't you have any idea how to fix it?

My application connects to EA several times and it makes me crazy I can't stop the previous processes which aren't active any more (but consume a significant amount of memory to let them be...).

And what's more - I've just noticed I can't create more than 7 EA processes - I tried to manually open more than 7 EA projects but all the processes (exceeding those 7 already existing) are automatically closed... Please, help!

Any hint is welcome.

Thanks,

Radek
Title: Re: How to force EA process to finish?
Post by: «Midnight» on October 03, 2007, 10:36:20 am
Why are you calling the Compact method?
Title: Re: How to force EA process to finish?
Post by: chrvi on October 03, 2007, 10:36:52 pm
...to free the memory consumed by EA.

But as I know it does nothing else than calling
System.gc();
System.runFinalization();
Title: Re: How to force EA process to finish?
Post by: «Midnight» on October 05, 2007, 02:49:14 am
Then I suggest you omit the call, or at least consider calling before you close the file. Ensure that the (any) reference to the repository object is set to null, then you can call the garbage collector. [If you've gotten rid of all EA references you'll likely not even need to do this.]

Also, remember that calling the GC explicitly will get things cleaned up, but the timing of the actual removal is up to .Net. According to MS this could be some time later.

David
Title: Re: How to force EA process to finish?
Post by: chrvi on October 16, 2007, 08:45:31 am
Soooo... I tried to set all possibly problematic data to null but the EA processes still remain in memory.

I've finally noticed the repository.exit() method in the Java API which closes the EA process and frees its memory which can seem to be the solution of my problem.

However, if I use the following code:
Code: [Select]

repository = new Repository();  
repository.OpenFile(A_Project_File);
...
repository.CloseFile();
   
repository = new Repository();  
repository.OpenFile(The_Same_File_As_Before);
...

the application sometimes crashes.
Probably Java goes through all the repository commands immediately but Enterprise Architect works asynchronously so that the Java "repository.OpenFile(The_Same_File_As_Before) may be called before Enterprise Architect actually closed the A_Project_File file and since the file isn't closed yet, it can't be opened by repository.OpenFile(The_Same_File_As_Before)

If I use repository.Exit() after repository.CloseFile() the problem is solved (the file is closed and can be reopened) but I'm not sure wheteher it is safe and whether the closed file contains all and correct data (as if no repository.Exit() was called).

Do you think it's safe to call repository.Exit()?
Does this method close the project file correctly and automatically?
Or can I lose some data when EA is forced to quit unexpectedly (while some processing is being active) after this method is called?

Thanks.
Title: Re: How to force EA process to finish?
Post by: «Midnight» on October 16, 2007, 09:50:37 am
Radek,

Since I never work with EA in the Java world I really don't know.

Anyone else have process-end issues or suggestions for EA and Java?

David
Title: Re: How to force EA process to finish?
Post by: jkorman on October 16, 2007, 12:25:41 pm
Try using the destroy method on Repository. It appears to call the destructor on the internal com object. I'm not sure how that differs from calling Repository.exit(), but I've been using destroy() in my test code and all appears fine.

Jim
Title: Re: How to force EA process to finish?
Post by: chrvi on October 17, 2007, 03:38:06 am
Well, the question is whether the data processed by EA will be correct after exit() or destroy() method is called.
I.e. whether exit() or destroy() methods let EA to finish its processing and close the EA process after that...