eXpandFramework / eXpand

DevExpress XAF (eXpressApp) extension framework. ๐—น๐—ถ๐—ป๐—ธ๐—ฒ๐—ฑ๐—ถ๐—ป.๐—ฒ๐˜…๐—ฝ๐—ฎ๐—ป๐—ฑ๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ.๐—ฐ๐—ผ๐—บ, ๐˜†๐—ผ๐˜‚๐˜๐˜‚๐—ฏ๐—ฒ.๐—ฒ๐˜…๐—ฝ๐—ฎ๐—ป๐—ฑ๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ.๐—ฐ๐—ผ๐—บ and ๐˜๐˜„๐—ถ๐˜๐˜๐—ฒ๐—ฟ @๐—ฒ๐˜…๐—ฝ๐—ฎ๐—ป๐—ฑ๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ and or simply ๐—ฆ๐˜๐—ฎ๐—ฟ/๐˜„๐—ฎ๐˜๐—ฐ๐—ต this repository and get notified from ๐—š๐—ถ๐˜๐—›๐˜‚๐—ฏ
http://expand.expandframework.com
Microsoft Public License
220 stars 114 forks source link

Out of memory using ModelCache #502

Closed vimarx closed 4 years ago

vimarx commented 5 years ago

After upgrading from 19.1.302 to 19.1.502 my solution fails with an out of memory exception when ModelCache is Enabled (x86)

There is any guideline to isolate what raises up memory consumption?

thanks!

The error occurred:

Type:       AggregateException
Message:    Se han producido uno o varios errores.
Data:       0 entries
Stack trace:

en System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) en System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) en DevExpress.ExpressApp.Win.WinApplication.SetupCore(String applicationName, IList`1 objectSpaceProviders, ApplicationModulesManager modulesManager, ISecurityStrategyBase security) en DevExpress.ExpressApp.XafApplication.Setup() en VxERP.Win.Program.Main(String[] arguments)

InnerException:

        Type:       OutOfMemoryException
        Message:    Se produjo una excepciรณn de tipo 'System.OutOfMemoryException'.
        Data:       0 entries
        Stack trace:

en System.Collections.Generic.List1.set_Capacity(Int32 value) en System.Collections.Generic.List1.EnsureCapacity(Int32 min) en System.Collections.Generic.List1.Add(T item) en DevExpress.ExpressApp.Model.Core.ModelNode.AddNodeIntoListCore(ModelNode node) en DevExpress.ExpressApp.Model.Core.ModelNode.AddNodeIntoList(ModelNode node) en DevExpress.ExpressApp.Model.Core.ModelNode.AddNodeCore(ModelNode node) en DevExpress.ExpressApp.Model.Core.ModelNode.AddNodeCore(String id, Type type) en DevExpress.ExpressApp.Model.Core.ModelNodeInfo.GenerateNodesByDefault(ModelNode parent) en DevExpress.ExpressApp.Model.Core.ModelNodesDefaultInterfaceGenerator.GenerateNodesCore(ModelNode node) en DevExpress.ExpressApp.Model.ModelNodesGeneratorBase.GenerateNodes(ModelNode node) en DevExpress.ExpressApp.Model.Core.ModelNode.RunNodesGenerator(ModelNodesGeneratorBase generator) en DevExpress.ExpressApp.Model.Core.ModelNode.RunNodesGenerator() en DevExpress.ExpressApp.Model.Core.ModelNode.EnsureNodes(Boolean alwaysCreate) en DevExpress.ExpressApp.Model.Core.ModelNode.GetUnsortedChildren(Boolean inThisLayer) en DevExpress.ExpressApp.Model.Core.ModelNode.GetChildrenForSerialization() en DevExpress.ExpressApp.Model.ModelCacheWriter.SerializeNodes(XmlElement xmlNode, ModelNode modelNode, XmlDocument currentDocument) en DevExpress.ExpressApp.Model.ModelCacheWriter.SerializeNode(ModelNode modelNode, XmlDocument document) en DevExpress.ExpressApp.Model.ModelCacheWriter.SerializeNodes(XmlElement xmlNode, ModelNode modelNode, XmlDocument currentDocument) en DevExpress.ExpressApp.Model.ModelCacheWriter.SerializeNode(ModelNode modelNode, XmlDocument document) en DevExpress.ExpressApp.Model.ModelCacheWriter.SerializeNodes(XmlElement xmlNode, ModelNode modelNode, XmlDocument currentDocument) en DevExpress.ExpressApp.Model.ModelCacheWriter.SerializeNode(ModelNode modelNode, XmlDocument document) en DevExpress.ExpressApp.Model.ModelCacheWriter.SerializeNodes(XmlElement xmlNode, ModelNode modelNode, XmlDocument currentDocument) en DevExpress.ExpressApp.Model.ModelCacheWriter.SerializeNode(ModelNode modelNode, XmlDocument document) en DevExpress.ExpressApp.Model.ModelCacheWriter.SerializeNodes(XmlElement xmlNode, ModelNode modelNode, XmlDocument currentDocument) en DevExpress.ExpressApp.Model.ModelCacheWriter.SerializeNode(ModelNode modelNode, XmlDocument document) en DevExpress.ExpressApp.Model.ModelCacheWriter.SerializeNodes(XmlElement xmlNode, ModelNode modelNode, XmlDocument currentDocument) en DevExpress.ExpressApp.Model.ModelCacheWriter.SerializeNode(ModelNode modelNode, XmlDocument document) en DevExpress.ExpressApp.Model.ModelCacheWriter.SerializeNodes(XmlElement xmlNode, ModelNode modelNode, XmlDocument currentDocument) en DevExpress.ExpressApp.Model.ModelCacheWriter.SerializeNode(ModelNode modelNode, XmlDocument document) en DevExpress.ExpressApp.Model.ModelCacheWriter.GetSplitModel(IModelNode modelNode) en DevExpress.ExpressApp.ModelCacheManager.SavePrimaryModel(ModelApplicationBase model, ModelCacheWriter writer, Dictionary2 serializedModel) en DevExpress.ExpressApp.ModelCacheManager.Save(ModelApplicationBase model) en DevExpress.ExpressApp.ApplicationModelManager.CreateUnchangeableLayer(ModelStoreBase[] modelDifferenceStores, Boolean cacheApplicationModelDifferences, ModelStoreBase applicationModelDifferenceStore) en DevExpress.ExpressApp.ApplicationModelManager.Setup(ITypesInfo typesInfo, IEnumerable1 boModelTypes, IEnumerable1 modules, IEnumerable1 controllers, IEnumerable1 applicationLocalizerTypes, IEnumerable1 applicationAspects, ModelStoreBase applicationModelDifferenceStore, String modelAssemblyFile) en DevExpress.ExpressApp.XafApplication.CreateModelManager(IEnumerable1 boModelTypes) en DevExpress.ExpressApp.Win.WinApplication.CreateModelManager(IEnumerable1 boModelTypes) en DevExpress.ExpressApp.XafApplication.Setup(ExpressApplicationSetupParameters parameters) en DevExpress.ExpressApp.XafApplication.SetupCore(String applicationName, IList1 objectSpaceProviders, ApplicationModulesManager modulesManager, ISecurityStrategyBase security) en DevExpress.ExpressApp.Win.WinApplication.<>n0(String applicationName, IList`1 objectSpaceProviders, ApplicationModulesManager modulesManager, ISecurityStrategyBase security) en DevExpress.ExpressApp.Win.WinApplication.<>cDisplayClass77_0.b__0() en System.Threading.Tasks.Task.InnerInvoke() en System.Threading.Tasks.Task.Execute() InnerException is null

apobekiaris commented 5 years ago

ModelCache is Enabled (x86)

whats your reason for this? my guess is that x64 won't fail

apobekiaris commented 5 years ago

there are some workarounds for this but cannot try as i cannot repro

https://bhrnjica.net/2012/07/22/with-net-4-5-10-years-memory-limit-of-2-gb-is-over/ https://blogs.msdn.microsoft.com/calvin_hsia/2010/09/27/out-of-memory-easy-ways-to-increase-the-memory-available-to-your-program/

vimarx commented 5 years ago

I'm using x86 because of performance reason

image

and I don't convince me to have a not-so-complex application witch rise its memory consumption to more than 2gb ... I think there is room for improvement. May I try by disabling ModelINheritance and model adapter modules? how can I do it?

apobekiaris commented 5 years ago
  1. x86 apps obey to the 2G limit
  2. The room from improvement as I see it is on the XAF side the Mapper doesn't to much than extending the model. You can try using the generated assembly without the Mapper, my guess is that it will fail the same. The assembly only contains interfaces.
  3. Did you already tried the docs suggestion? https://github.com/eXpandFramework/DevExpress.XAF/tree/master/src/Modules/ModelMapper#issues-debugging-troubleshooting
apobekiaris commented 5 years ago

reading the quote from DevExpress again, it leads to the conclusion that without measurements you should not use outdated targets. It refers to some XAF winforms is your one of them? NGen suugestion also is outdated to my knowldege again is about some cases furthermore MS developed a newer protocolas a replacement to this.

Also note the XVideoRental is using a large model as many modules with ModelMapper are installed and no issues there.

please try the suggestions i posted at and let me know https://github.com/eXpandFramework/eXpand/issues/502#issuecomment-520158335

vimarx commented 5 years ago

I dont understand "outdated targets. It refers to some XAF winforms"??

apobekiaris commented 5 years ago

i meant x86 as a target platform

apobekiaris commented 5 years ago

apparently the ME is using arrays that cannot scale thats why u have this issue. I am not sure I just guess

vimarx commented 5 years ago

also I can't disable ModelMapper as suggested in ((Xpand.XAF.Modules.ModelMapperModule) Application.Modules.FindModule(typeof(Xpand.XAF.Modules.ModelMapperModule))).Unload();

because out of memory occurs before Setup completes

vimarx commented 5 years ago

I compiled as Any CPU and now it starts properly, but its memory consumption during cache or model creation rises to 3.0Giga of RAM!, so I think there is something to look at there

apobekiaris commented 5 years ago

additional notes: XVideorental is compiled on x86 and with ModelCache enable it peeks to 1G with an average of 500Mb.

Having a repro sample we can delegate the problem to DX support

expand commented 4 years ago

Closing issue for age. Feel free to reopen it at any time.

.Thank you for your contribution.