OutSystems.SetupTools
OutSystems.SetupTools copied to clipboard
Out of memory issue when executing Publish-OSPlatformModule function
After an upgrade to the latest version of the platform IDE, when republishing over 400 modules using the line below, I always run into a out of memory issue in PowerShell. I have 12GB of ram on my server. Is that not enough? Is there a limitation to how many modules the script can republish at once? Am I running the script incorrectly?
Get-OSPlatformModules -Credential $SCCreds -PassThru -Filter {$_.StatusMessages.Id -eq 13} -ErrorAction Stop | Publish-OSPlatformModule -Wait -Verbose -ErrorAction Stop | Out-Null
After reviewing the logs, it generates the OutofMemory after about 2 hours of powershell executing....
VERBOSE : 2021-10-19 19:02:52.4800 [Publish-OSPlatformModule ] [PROCESS] Service Center: Preparing Deploy - Preparing deploy of module 'Logging_Lib'. VERBOSE : 2021-10-19 19:02:54.7457 [Publish-OSPlatformModule ] [PROCESS] Service Center: Preparing Deploy - Preparing deploy of module 'LoginHistory'. ERROR : 2021-10-19 19:02:56.8707 [Publish-OSPlatformModule ] [PROCESS] Error checking the publication status ( Publish Id: 3590 ) InnerException: Exception of type 'System.OutOfMemoryException' was thrown. at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at System.Reflection.Assembly.CreateInstance(String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at Microsoft.PowerShell.Commands.NewWebServiceProxy.InstantinateWebServiceProxy(Assembly assembly) at Microsoft.PowerShell.Commands.NewWebServiceProxy.BeginProcessing() at System.Management.Automation.Cmdlet.DoBeginProcessing() at System.Management.Automation.CommandProcessorBase.DoBegin()
Hi @wartang. Yes, you're totally right. This is know problem cause we are creating a New-WebServiceProxy on each request instead of re-using an existing one. Even while checking for publication results.
https://github.com/OutSystems/OutSystems.SetupTools/blob/be27ed66e30f1a2cd04102740e2e24ec5272bb0d/src/Outsystems.SetupTools/Lib/ServiceCenterWebServices.ps1#L7
Feel free to PR with a fix if you want.
Thanks for the reply. Would you possibly have a fix for me to implement so it doesn't keep creating a New-WebServiceProxy on each request? We have a lot of modules so I would love to use this command. I am unsure what to change or update myself
Is someone able to provide a fix so the script re-uses the existing request instead of recreating it every time, causing it to eventually run out of memory?
Does anybody have a fix or a workaround for this out of memory issue yet? Hoping someone has an idea on how to run the publishing script since the number of modules are only increasing over time.