Book a Demo

Author Topic: How to force EA process to finish?  (Read 5629 times)

chrvi

  • EA User
  • **
  • Posts: 75
  • Karma: +0/-0
  • There are so many hidden features...
    • View Profile
How to force EA process to finish?
« 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
« Last Edit: October 03, 2007, 09:54:14 am by chrvi »
Radek

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: How to force EA process to finish?
« Reply #1 on: October 03, 2007, 10:36:20 am »
Why are you calling the Compact method?
No, you can't have it!

chrvi

  • EA User
  • **
  • Posts: 75
  • Karma: +0/-0
  • There are so many hidden features...
    • View Profile
Re: How to force EA process to finish?
« Reply #2 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();
Radek

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: How to force EA process to finish?
« Reply #3 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
No, you can't have it!

chrvi

  • EA User
  • **
  • Posts: 75
  • Karma: +0/-0
  • There are so many hidden features...
    • View Profile
Re: How to force EA process to finish?
« Reply #4 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.
« Last Edit: October 16, 2007, 08:51:08 am by chrvi »
Radek

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: How to force EA process to finish?
« Reply #5 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
No, you can't have it!

jkorman

  • EA User
  • **
  • Posts: 99
  • Karma: +0/-0
    • View Profile
Re: How to force EA process to finish?
« Reply #6 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

chrvi

  • EA User
  • **
  • Posts: 75
  • Karma: +0/-0
  • There are so many hidden features...
    • View Profile
Re: How to force EA process to finish?
« Reply #7 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...
Radek