all groups > dotnet remoting > april 2006 >
You're in the

dotnet remoting

group:

Memory Leak/Problem with Remoting


Memory Leak/Problem with Remoting HeatherS
4/26/2006 12:36:02 PM
dotnet remoting:
We are hosting our remoting through windows services. The remote class is
basically a data access component. So, in the client application will call
the remoting object passing in a stored procedure and its parameters and the
function passes back a dataset. The problem is that if you watch in task
manager the memory usage increases but nevers goes down. I would appreciate
any help in helping to troubleshooting this. We have tried to rewrite the
code several different ways and set the remoting service to SingleCall and
Singleton but can't seem to pin down the problem. I have included some code
below to show what we are doing basically, but I am not sure what else to
look for or what would be helpful. Thanks in advance!


The call to the remoting object:
Dim myDal As DAL = CType(Activator.GetObject(GetType(DAL),
"tcp://server:1234/DAL.rem"), DAL)
Dim ds As DataSet = myDal.ExecuteSPReturnDataSet("spGetLogger")
DataGrid1.DataSource = ds.Tables(0)
ds.Dispose()
ds = Nothing
myDal = Nothing
GC.Collect()

The class in the remoting service:
Public Class DAL : Inherits MarshalByRefObject

The function that is called in the remoting service:
Public Function ExecuteSPReturnDataSet(ByVal strSpName As String, Optional
ByVal arrParamDetails As ArrayList = Nothing) As DataSet
Dim ds As DataSet

Try
ds = objDbAccess.ExecuteSPReturnDataSet(strSpName,
arrParamDetails)
Return ds

Catch ex As Exception
Throw ex

Finally
ds.Dispose()
ds = Nothing
GC.Collect()
End Try
Re: Memory Leak/Problem with Remoting Spam Catcher
4/26/2006 10:17:46 PM
=?Utf-8?B?SGVhdGhlclM=?= <HeatherS@discussions.microsoft.com> wrote in
news:9153429B-15C6-4175-8642-D9714C60E3F2@microsoft.com:

[quoted text, click to view]

Are you sending large data sets back to the client?

Re: Memory Leak/Problem with Remoting oleksa
4/27/2006 1:52:59 AM
Hello.

Is there [MTAThread] attribute in the Main method of yours Service
class?
I've got the same problem as you (C# remoting hosting service memory
always grows) and this attribute has solved the problem.

See http://udidahan.weblogs.us/archives/015716.html for details.
Re: Memory Leak/Problem with Remoting HeatherS
4/27/2006 9:23:03 AM
They are not large datasets. We ran into that problem already and after some
research wrote a surrogate class to serial the dataset differently. I am not
as concerned that it uses memory though, but that it never gives it back.
So, it doesn't matter if it is small datasets, eventually the service maxs
out its the memory allocated to it.

[quoted text, click to view]
Re: Memory Leak/Problem with Remoting HeatherS
4/27/2006 9:24:02 AM
I saw that posting too. I did check and it is marked as MTAThread. Thanks
for the suggestion though.

[quoted text, click to view]
Re: Memory Leak/Problem with Remoting Martin S.
5/5/2006 2:00:02 AM
I have the same problem with a StringWriter. Obviously it doesn't mind if I
retrun a String. I think some "Objects" aren't serialized correct through
..NET Remoting.
But I've already seen posts about successfully returned DataSets. Maybe can
give some more background about this whole topic ?

[quoted text, click to view]
Re: Memory Leak/Problem with Remoting HeatherS
5/5/2006 6:39:02 AM
Actually, I am pretty sure we solved it. I was so busy focusing on the class
that the remoting service exposed that I didn't pay attention to the service
itself. I was reading a post somewhere about a memory running amok if you
used RemotingConfiguration.Configure("Client.exe.config") in the service, we
don't do that, but I thought maybe global variables would do the same. So I
checked and the code was written with the port numbers being held in global
variables (not sure why but whatever), so I cleaned those up made them local
to a procedure and removed some code from the constructor for the service and
viola, it seems to be working. We haven't put it in produciton yet, but when
we tax it in Dev and Beta all is well.

[quoted text, click to view]
AddThis Social Bookmark Button