Memory Leak in RemotableObject (VSNET1.1)

V

victor

Hi,
In my Remoting project there exists a service, which returns an image
stream per client call (each second).
Everything seems to operate well, except that it produces a mem-leak
on the Server side: TaskManager MemUsage counts up constantly.
Code snippets:
--------------
@Client:
mystream=remoteObject(SendImageStream(filename));
....

@Server/R_Object:
public object SendImageStream(string Filename)
{
FileStream fs=new(Filename,FileMode.Open,..etc....);
int length=(int)fs.Length;
byte[] buffer=new byte[length];
fs.Read(buffer,0,length);
fs.Close();
return new MemoryStream(buffer,0,length,false,false);
}
----------------
Debugging reveals that out of those 3 'new' occurences, the 'new
byte....' is causing the troubles.
It looks like logical, cause the Client needs the buffer data, so the
GC doesnot collect this item (even if I forced it through GC.Collect,
it'll still produce the leak).

Please advise on how to solve this situation.
Thanks ahead!

victor.
 
N

Nicholas Paldino [.NET/C# MVP]

victor,

It's not a leak. Seeing memory usage go up in Task Manager is actually
^expected^ behavior for ANY .NET application.
 
V

victor

Hi Nicholas,
Thanks for responding.
I apologise for being not thorough in my posting: the thing is, the
mem usage keeps counting up till it hits its ceiling (1GB on my
machine), and then the app dies .... . The reason is: a memory stream
buffer being returned from the RO to the Client. I can work around
this situation by making the buffer static, but that produces other
side effects I donot want.
Surfing the net I've found an article on
<http://www.thinktecture.com/Resources/RemotingFAQ/Lifetime.html>,
titled "The mysteries of Distributed Garbage Collection", where was
stated that the GC *cannot* perform its task on remote objects.
Do you have any comments on that?
greetz, victor.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top