In your code:
public void Fill(int sysuserid, string dbconnection)
{
// DateTime start = new DateTime(DateTime.Now.Ticks);
SqlConnection _conn = new SqlConnection( dbconnection);
SqlCommand _comm = new SqlCommand("Get_RxWorks_Menues",_conn);
_comm.CommandType = CommandType.StoredProcedure;
SqlParameter _param = new SqlParameter("@sysuserid",sysuserid);
_comm.Parameters.Add(_param);
SqlDataAdapter _da = new SqlDataAdapter(_comm);
_da.Fill(_table);
// DateTime end = new DateTime(DateTime.Now.Ticks);
// MessageBox.Show(end.Subtract(start).TotalMilliseconds.ToString());
}
The SqlConnection is not closed. If the SqlConnection goes out of scope, it won't be closed. Therefore, you must explicitly close the connection by calling Close or Dispose. Close and Dispose are functionally equivalent.
If the connection pooling value Pooling is set to true or yes, the underlying connection is returned back to the connection pool. On the other hand, if Pooling is set to false or no, the underlying connection to the server is actually closed.
This could be the reason why the memory goes up.
To use SqlConnection properly, you can follow this:
using (SqlConnection connection = new SqlConnection(connectionString))
{
// Do work here; connection closed on following line.
}
Please read the MSDN for details
Please also check if the UI objects you're using should be disposed explicitly as UI object will allocate native handles.