Author Topic: .Net: EA process not closing - GC not cleaning up  (Read 5368 times)

JayBee15

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
.Net: EA process not closing - GC not cleaning up
« on: March 13, 2015, 11:50:01 pm »
Have an issue with c# code leaving EA processes alive after the code is complete. There is a suggestion this situation happens on the Examples and Tips page and that coding a forced garabge collection will cleanup the released repository instance (via Repository.Exit). This is not working and the EA process still hangs around.
Using Win7 with EA11.
Has anyone else hit this and been able to resolve it? I am not entertaining dumping the contents of all the processes and looking for any that are EA and killing the PID ... that's just terrible brute force form and bad practice. Surely there must be a more elegant way. More than that there is no reason for the EA process to be left in a state that it is not released when the code is complete.

OpenIT Solutions

  • EA User
  • **
  • Posts: 555
  • Karma: +9/-1
    • View Profile
Re: .Net: EA process not closing - GC not cleaning
« Reply #1 on: March 14, 2015, 03:28:10 am »
You have your repository.exit in a finally block ? And your set repository = null; ?

That's always been enough for me - not even had to force/manually gc.

JayBee15

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: .Net: EA process not closing - GC not cleaning
« Reply #2 on: March 14, 2015, 04:43:08 am »
The Exit is executed (watching via debugger). Yes to the null.

This only became a problem when the OS was upgraded to Win7 64 bit. Never had this issue until then.

Sparx seems to know there is an issue since they have the code for the forced garbage collection on the Examples and Tips page. Unfortunately this is not doing the trick. I can run the code several times in a row and cause the memory to leak right away.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: .Net: EA process not closing - GC not cleaning
« Reply #3 on: March 14, 2015, 10:21:25 am »
You should contact Sparx support via mail about this issue.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: .Net: EA process not closing - GC not cleaning
« Reply #4 on: March 16, 2015, 08:37:23 am »
I did see an issue that was fixed for 12, that Exit wouldn't work unless you had loaded a model. Is there any chance that's your problem?

EXploringEA

  • EA User
  • **
  • Posts: 172
  • Karma: +8/-0
    • View Profile
Re: .Net: EA process not closing - GC not cleaning
« Reply #5 on: March 17, 2015, 10:21:13 pm »
One thought - is your AddIn interacting with any other process e.g. Using a com service - if it is then the problem could be related to that.

When I am using com services I usually track the relevant processes and  when EA is closing I check if the processes have ended, and as necessary kill them :-X but not often, so I can ensure they are closed otherwise EA can hang.

Of course, if you're not doing this then this suggestion won't  apply.
« Last Edit: March 17, 2015, 10:21:33 pm by MrWappy »
EXploringEA - information, utilities and addins

JayBee15

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: .Net: EA process not closing - GC not cleaning
« Reply #6 on: March 21, 2015, 12:48:31 am »
Simon,
>>that Exit wouldn't work unless you had loaded a model
A model has been loaded so this is not the scenario

MrWappy,
It is not interacting with any other com service. It is easily reproduced by simply creating a small c# program that creates an instance of EA, loads an existing model, and shuts it all back down.

Thanks to both for your suggestions.

JayBee15

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: .Net: EA process not closing - GC not cleaning
« Reply #7 on: March 22, 2015, 04:49:12 am »
Simon,
>>that Exit wouldn't work unless you had loaded a model
JB: >>A model has been loaded so this is not the scenario

Turns out this is not exactly as stated. There is a part of the code that instantiates a repository then exits it without loading a model. I tested the same code in 12 and the process was cleaned up appropriately.

So here are my findings thus far.

Sparx 10: Instantiate Repository, do nothing else and shut down the code. The EA process is garbage collected properly.
Sparx 11: Do the same as above. The process is left after the program exits and is not garbage collected. Only is destroyed if a model is opened and the Repository is exited.
Sparx12: Do the same as described in the 1st scenario and the process is still left hanging. Add the Repository exit and the process is removed.

The end result of all this is some code needs to be changed in order to get the process to cleanup properly. Suppose it was bad form in the 1st place to leave the Repository object hanging around without cleaning it up. However, there is still an issue still if the code that instantiated the Repository is killed without having a chance to clean up the Repository. This will result in EA processes left out there.