SDK Connection Open/Close K2Process.exe service memory leak?


Badge +3

Hey I'm doing the following in custom code using the K2 SDK:


 using (Connection K2Con = new Connection())


{


ConnectionSetup K2ConSetup = new ConnectionSetup();


K2ConSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.Host, ConfigurationManager.AppSettings["K2Server"]); // server name on the network


K2ConSetup.ConnectionParameters.Add(ConnectionSetup.ParamKeys.TimeOut, ConfigurationManager.AppSettings["K2ConnTimeOut"]); // set to 2


//Open a connection to the K2[blackpearl] server


K2Con.Open(K2ConSetup);


K2Con.ImpersonateUser(Profile.GetValue(

"WindowsLogin"));


nameLabel.Text = K2Con.User.Name;


Worklist K2WorkList = K2Con.OpenWorklist("ASP");


K2Con.RevertUser();


 ... more code


K2Con.Close()


}


 


Every time this code is run the K2Process.exe service keep grabbing more memory about 8Kb at a time and won't give it back to the OS.  Is there something I'm missing in the above to make the K2Process.exe give back memory to the OS?


 Once it starts to consume around 900MB of ram we have to restart the service b/c it's non responsive.


 Thanks in advance,


 Scott


4 replies

Badge +9

Does this occur every time you connect to the Workflow.Client API or just when you retrieve your worklist items (via the OpenWorklist() call)? 


Also are you running blackpearl SP1 or 0803?


Thanks.

Badge +11

I didn't notice this until recently and I don't think I've seen it in other samples, but the Connection class has a Dispose method.  As a general .NET rule, anything that implements IDisposable should have the Dispose method called when you're done.  It's also a good practice to put the Open/Close/Dispose inside of a try/catch/finally to make sure all connections get closed even if there is an exception. 


Post back and let us know if that makes a difference.

Badge +3

We're going to apply the latest service pack soon.


 Regarding the dispose call, if you wrap the object creation with a using clause it will call dispose on the object if it implements IDisposable.  But I'll try it with the finally clause when I get a chance to see if that makes a difference.


 Scott

Badge +3
Looks like SP1 has fixed this.

Reply