|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2012-01-26 14:59:09
Posts: 242,
Visits: 828
|
|
| Hi, why there is difference in the following behaviours:? 1. a. Open a form that loads 1000 Eco objects b. Close the form c. EcoSpace.Active = false; EcoSpace.Active = true; Result: 1000 objects loaded 2. a. Loading the same 1000 objects with IObjectList iol = EcoServiceHelper.GetExtentService(rhRoot.EcoSpace).AllInstances(typeof(DatenpunktDef)); iol.EnsureObjects(); b. EcoSpace.Active = false; EcoSpace.Active = true; Result: 0 objects loaded The only difference I see is that iol is a local variable in a method of the test form, whereas the form in scenario 1. is a private member of the test form. But If I use .Close() on the form containig 1000 objects it doesn't chenge the behaviour. What's the matter?
/Efim
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2012-01-26 14:59:09
Posts: 242,
Visits: 828
|
|
| The positive result can be achieved if the local reference on the form in question is set to null and GC.collect() is called. The only thing I don't like is that it should be done in the calling form: private MyCalledForm myCalledForm = null; .................................. if (myCalledForm == null) myCalledForm = new MyCalledForm(EcoSpace);myCalledForm.Show();........................ if (myCalledForm != null){ myCalledForm = null; GC.Collect(); EcoSpace.Active = false; EcoSpace.Active = true;} Can I achieve the same without holding the local form reference (myCalledForm in this case) in the calling form? I tried already to do the same in FromClosed event of the MyCalledForm, but it didn't work.
/Efim
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2011-07-14 17:05:00
Posts: 290,
Visits: 2 617
|
|
All you need to do is to create an instance of the 2nd form, have the 2nd form own its own EcoSpace instance. When the form is collected the memory will be collected, which may not be immediately but rather when the .NET GC decides it is needed.
====
Pete
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2012-01-26 14:59:09
Posts: 242,
Visits: 828
|
|
| Hi Pete, Yes, I had in mind this solution, but I'm not sure so far what other problems can appear when working with multiple EcoSpaces. For ex. when 2 forms have common data or when synchronizing with EcoSpaces of other clients using Remote Persistence.
/Efim
|
|
|
|