Sunny
6/17/2004 2:17:00 PM
Hi,
the default lifetime values for a remoting object are:
initial lifetime - 5 min
on call renew - 2 minutes
Your remoting object is not a candidate for GC during that period.
Try to decrease the lifetime policy for that object, and then try again.
Also, even said GC.Collect should force the collection, there is no
guarantee when and how it will happen.
Sunny
In article <e4FVW8DVEHA.1888@TK2MSFTNGP11.phx.gbl>, huangsy@stpass.com
says...
> I''ve written a simple application to test the remoting scenario, and find
> out that the client activated object''s destructor was never called until
> server application was down.
> the application is simple.
>
> The remoting object
>
> public class RemotingObject:MarshalByRefObject
> {
> private string _id;
> public RemotingObject()
> {
> Console.WriteLine("Someone Called me");
> }
> ~RemotingObject()
> {
> Console.WriteLine("Someone killed " + _id);
> }
>
> public string ID
> {
> get
> {
> return _id;
> }
> set
> {
> _id = value;
> }
> }
> }
>
> the server app
>
> class Class1
> {
> /// <summary>
> /// /// </summary>
> [STAThread]
> static void Main(string[] args)
> {
> TcpServerChannel tsc = new TcpServerChannel(8228);
> ChannelServices.RegisterChannel(tsc);
>
> RemotingConfiguration.RegisterActivatedServiceType(typeof(RemotingObject.Rem
> otingObject));
> Console.WriteLine("");
>
> String keyState = "";
> while (String.Compare(keyState,"0") != 0)
> {
> Console.WriteLine("Press a key and ENTER: G=GC.Collect, 0=Exit");
> keyState = Console.ReadLine();
>
> Console.WriteLine("Pressed: " + keyState);
>
> // Force a GC
> if (String.Compare(keyState,"G") == 0)
> {
> Console.WriteLine("GC Collect - start");
> GC.Collect();
> GC.WaitForPendingFinalizers();
> Console.WriteLine("GC Collect - done");
> }
> }
> }
> }
>
> and the client
>
> [STAThread]
> static void Main(string[] args)
> {
> TcpChannel chan = new TcpChannel();
>
> ChannelServices.RegisterChannel(chan);
>
> System.Runtime.Remoting.RemotingConfiguration.RegisterActivatedClientType(ty
> peof(RemotingObject.RemotingObject),"tcp://localhost:8228");
>
> object[] attrs = {new
> System.Runtime.Remoting.Activation.UrlAttribute("tcp://localhost:8228/Remoti
> ngObject")};
> System.Runtime.Remoting.ObjectHandle handle =
> Activator.CreateInstance("RemotingObject","RemotingObject.RemotingObject",at
> trs);
>
> if (handle == null)
> {
> MessageBox.Show("Failed");
> return;
> }
> RemotingObject.RemotingObject _ro =
> (RemotingObject.RemotingObject)handle.Unwrap();
> _ro.ID="asdqw";
> Console.WriteLine(_ro.ID);
> }
>
> did i miss something.
> Thanks in advance.
>
> shawn
>
>
>