Question
scotiabankcolpatria
MX
Last activity: 2 Mar 2022 16:43 EST
I have a memory problem
Good morning, I have problems with an automation and I don't know how to attack it. In one part of the process I perform a data crossing by custom methods, but I get an exception of type: System.OutOfMemoryException... I would like to know if there is any way to proceed with this type of error
-
Like (0)
Sindhuja Alla -
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
US
@carlosr32 You would need to provide some more information before I could really offer any specific suggestions. Generally speaking however, Out-Of-Memory exceptions happen when you don't allow the stack of automations steps to "unwind". This happens usually when developers use Jump Labels as loops instead of using a ForLoop. Is that a possibility in your case?
You might also look at the stack trace shown in your exception as it would indicate the method that caused it. If this is your custom method, then you would need to add some logging or other means of troubleshooting into your code. When you say "perform a data crossing by custom methods", what do you mean by that?
Any automation screenshots, sample code, or a RuntimeLog that you can provide may be helpful to provide specific guidance. Just make sure you remove anything that might be non-public information.
scotiabankcolpatria
MX
thank you very much for your prompt response.
When I talk about data crossing, I mean that I have a number of records in the file and I must cross that information through a column in common with another data table with records.
thank you very much for your prompt response.
When I talk about data crossing, I mean that I have a number of records in the file and I must cross that information through a column in common with another data table with records.
the error in the stack trace is something like this: Info | 12:25:02.067 p. m. | 51 | MTA | Automation | FLE_P_ValidarYProcesarBaseOneSbc | FlujoExoneracion | Automation: FLE_P_ValidarYProcesarBaseOneSbc - ExecutionLink From: FLT_GC.FLT_GC_MetodosPersonalizados.GetElementoConfiguracion() To: FLT_GC.FLT_GC_MetodosPersonalizados.LeerConsolidado() ID: 7319c38c-e70a-4b87-a919-6f511bf83729 Info | 12:25:02.067 p. m. | 51 | MTA | Automation | FLE_P_ValidarYProcesarBaseOneSbc | FlujoExoneracion | Automation: FLE_P_ValidarYProcesarBaseOneSbc propagating From: FLE_P_ValidarYProcesarBaseOneSbc.pathConcoslidado.This To FLT_GC.FLT_GC_MetodosPersonalizados.LeerConsolidado().rutaConsolidado Value: D:\Users\s4649477\Documents\CORPA_83\Salida\WMTXONE1.txt Info | 12:25:03.680 p. m. | 51 | MTA | Automation | FLE_P_ValidarYProcesarBaseOneSbc | FlujoExoneracion | Automation: FLE_P_ValidarYProcesarBaseOneSbc - ExecutionLink From: FLT_GC.FLT_GC_MetodosPersonalizados.LeerConsolidado() To: FLT_GC.FLT_GC_MetodosPersonalizados.LeerDetalle() ID: 7319c38c-e70a-4b87-a919-6f511bf83729 Info | 12:25:03.680 p. m. | 51 | MTA | Automation | FLE_P_ValidarYProcesarBaseOneSbc | FlujoExoneracion | Automation: FLE_P_ValidarYProcesarBaseOneSbc propagating From: FLE_P_ValidarYProcesarBaseOneSbc.pathDetalle.This To FLT_GC.FLT_GC_MetodosPersonalizados.LeerDetalle().rutaDetalle Value: D:\Users\s4649477\Documents\CORPA_83\Salida\WMTXONE.txt Info | 12:25:23.911 p. m. | 51 | MTA | Automation | FLE_P_ValidarYProcesarBaseOneSbc | FLT_GC_MetodosPersonalizados-25943868 | LeerDetalle: Exception invoking method - Se produjo una excepción de tipo 'System.OutOfMemoryException'.
On the other hand I would like to clarify... suppose that the process has 3 parts a,b,c The robot does parts a and b without problems, but when it reaches part c it has a memory problem. If I run part a and b, I turn off the robot and configure it to run only part c, it does so without a problem, but if I let it run completely, that is, a b and c there I present the error.
Pegasystems Inc.
US
@carlosr32 I would look into your script. It is possible that the file you are opening is to large and needs to be broken up or processed differently.
FLT_GC.FLT_GC_MetodosPersonalizados.LeerConsolidado().rutaConsolidado Value: D:\Users\s4649477\Documents\CORPA_83\Salida\WMTXONE1.txt Info
I am assuming that FLT_GC is a global container and FLT_GC_MetodosPersonalizados is a script component and LeerConsolidado is a method in that script. You might need to look into that code to see what the issue code be. Are you able to post that code?
scotiabankcolpatria
MX
Hello, The method I am using to read the information is this:
public void LeerDetalle(string rutaDetalle, out string response) { response = ""; DataTable dtAux = new DataTable(); dtAux.Columns.Add("col1"); dtAux.Columns.Add("col2"); dtAux.Columns.Add("col3"); dtAux.Columns.Add("col4"); DataTable dtAux2 = new DataTable(); dtAux2.Columns.Add("col1"); dtAux2.Columns.Add("col2"); var engine = new FileHelperAsyncEngine<Detalle>(); using (engine.BeginReadFile(rutaDetalle)) { // The engine is IEnumerable int count = 0; foreach (Detalle row in engine) { dtAux.Rows.Add(row.col1.Replace("\"",""),row.col2,row.col3,row.col4.Replace("\"","")); } response += count + "\n"; count = 0; } DataTable dt = dtAux.AsEnumerable() .GroupBy(r => new { Doc = r["col1"], Bin = r["col4"]}) .Select(g => { var row = dtAux2.NewRow(); row["col1"] = g.Key.Doc; row["col2"] =g.Key.Bin; //row["col3"] = g.Max(r => r.Field<DateTime>("col3")); //row["col4"] = g.Max(r => r.Field<string>("col4")); return row; }).CopyToDataTable(); //MessageBox.Show(dt.Rows.Count.ToString()); dtDetallesGlobal = dt; }
scotiabankcolpatria
MX
Sorry, the code is this:
public void LeerConsolidado(string rutaConsolidado) { DataTable dtAux = new DataTable(); DataRow[] query; DataRow[] query2; string aux= "", aux1 = "", aux2 ="", aux3 ="", aux4 =""; dtAux.Columns.Add("col1"); dtAux.Columns.Add("col2"); dtAux.Columns.Add("col3"); dtAux.Columns.Add("col4"); dtAux.Columns.Add("col5"); dtAux.Columns.Add("col6"); dtAux.Columns.Add("col7"); dtAux.Columns.Add("col8"); //dtAux.Columns.Add("col9"); var engine = new FileHelperAsyncEngine<Consolidado>(); using (engine.BeginReadFile(rutaConsolidado)) { // The engine is IEnumerable foreach (Consolidado row in engine) { dtAux.Rows.Add(row.col1,row.col2,row.col3,row.col4,row.col5,"","",""); } }
dtConsolidadoGlobal = dtAux; }
scotiabankcolpatria
MX
@ThomasSasnett what do you think of the code?
Pegasystems Inc.
US
@carlosr32 It is calling other sub-methods and things I can't see. Because one of those is named ReadFile though, I suspect that is where you are getting your exception. I believe .Net has limitations on certain methods of opening and reading files. Perhaps your is too large.
scotiabankcolpatria
MX
Excuse me, I'll send you the code in an image, maybe it looks better
Pegasystems Inc.
US
@carlosr32 I can't really comment further on that object as I don't have any experience with it, however I am fairly certain that is where your problem lies. When you look at the exception in your log, you should see a StackTrace. This outlines the steps that were being executed when the exception occurred. I would be that it points right here.
scotiabankcolpatria
MX
During the execution of the bot, data reading is performed in several parts. Suppose there are 3 parts. if you execute them separately, the exception is not presented. But if I run the whole process one part after another, on the last data read, the exception is thrown.
in both cases I use the same amount of data.
It is as if executing the entire process accumulates the internal memory of the bot. since separately if it does. Is it possible to free up memory space while the bot is running?
Pegasystems Inc.
US
@carlosr32In your automation, avoid using jump labels as loops and instead use a proper ForLoop. That will free up the stack after each execution. Can you post the stack trace from your exception?
scotiabankcolpatria
MX
Pegasystems Inc.
US
@carlosr32At the bottom of the exception in the RuntimeLog is a section labelled Stack Trace Information. It would show something like this (this is just the first exception I found in a log). I am not sure what the worrding would be in Spanish, but you can look for the asterisks.
StackTrace Information *********************************************
Server stack trace:
Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at OpenSpan.Virtual.Web.Interfaces.IVirtualBrowser.GetWindowDescriptorJson(ObjectUri& o, Int32 windowId) at OpenSpan.Adapters.Web.WebBase.Targets.VirtualBrowserTarget.GetBrowserWindowDescriptor(Int32 browserNativeWindowId) at OpenSpan.Adapters.Web.WebBase.VirtualBrowserFormTarget.get_Handle()
scotiabankcolpatria
MX
Pegasystems Inc.
US
@carlosr32 It looks like it is occurring within that script. Without seeing your entire solution, I can't really comment any further than what has been said so far. Make sure you are not looping in your automation without using a ForLoop. If you are storing anything, make sure you clean it up when not needed, etc...
You can open a support request if you'd like to provide the solution to our support team. They should be able to help determine the issue once they can get their hands on your solution.