473,322 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Memory Leak in RemotableObject (VSNET1.1)

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.
Aug 28 '06 #1
2 1518
victor,

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

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"victor" <vi****@somewhere.comwrote in message
news:t3********************************@4ax.com...
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.

Aug 28 '06 #2
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.
------------------------------------------------------------------------------------
On Mon, 28 Aug 2006 11:40:25 -0400, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.comwrote:
>victor,

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: ranjeet.gupta | last post by:
Dear All Is the Root Cause of the Memory corruption is the Memory leak, ?? suppose If in the code there is Memory leak, Do this may lead to the Memory Corruption while executing the program ? ...
17
by: José Joye | last post by:
Hi, I have implemented a Service that is responsible for getting messages from a MS MQ located on a remote machine. I'm getting memory leak from time to time (???). In some situation, it is...
4
by: Don Nell | last post by:
Hello Why is there a memory leak when this code is executed. for(;;) { ManagementScope scope = new ManagementScope(); scope.Options.Username="username"; scope.Options.Password="password";...
20
by: jeevankodali | last post by:
Hi I have an .Net application which processes thousands of Xml nodes each day and for each node I am using around 30-40 Regex matches to see if they satisfy some conditions are not. These Regex...
23
by: James | last post by:
The following code will create memory leaks!!! using System; using System.Diagnostics; using System.Data; using System.Data.SqlClient; namespace MemoryLeak
8
by: Adrian | last post by:
Hi I have a JS program that runs localy (under IE6 only) on a PC but it has a memory leak (probably the known MS one!) What applications are there that I could use to look at the memory usage of...
7
by: Salvador | last post by:
Hi, I am using WMI to gather information about different computers (using win2K and win 2K3), checking common classes and also WMI load balance. My application runs every 1 minute and reports...
3
by: Jim Land | last post by:
Jack Slocum claims here http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript- memory-leaks/ that "almost every site you visit that uses JavaScript is leaking memory". ...
22
by: Peter | last post by:
I am using VS2008. I have a Windows Service application which creates Crystal Reports. This is a multi theaded application which can run several reports at one time. My problem - there is a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.