I don't believe that SuppressFinalize does what you are thinking here. 

A call to SuppressFinalize sets a bit on the object that tells the GC
not to move this object to the freachable queue from the finalization
list. Thus the object will never be finalized when reclaimed.

In other words SuppressFinalize merely tells the GC not to call the
finalize method just reclaim the memory, and not 'don't reclaim this
memory'. It does not pin the object in memory "forever". Something like
that could be done with a WeakReference possibly, but this is not needed
in this scenario. 

In this scenario having the static member will keep a root reference to
this singleton(once it is created) for the life of this process. And it
will never be GC'd. That is all you need.

-Bill Conroy

-----Original Message-----
From: franklin gray [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, May 29, 2002 4:30 PM
To: [EMAIL PROTECTED]
Subject: Re: [ADVANCED-DOTNET] singleton server problem


so the object will stay in memory after all references have been
disposed.  That was when you come back to it later, it is still there
with the same data.

-----Original Message-----
From: Bill Conroy [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 29, 2002 3:21 PM
To: [EMAIL PROTECTED]
Subject: Re: [ADVANCED-DOTNET] singleton server problem


>> GC.SuppressFinalize(mCurrentUser)

Why this call?

-bc

-----Original Message-----
From: franklin gray [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, May 29, 2002 4:01 PM
To: [EMAIL PROTECTED]
Subject: Re: [ADVANCED-DOTNET] singleton server problem


exactly how do you have you singleton object coded?  

This is how I do mine.  If you do it this way, then there isn't any way
to register it as a singleton object that I know of.  The system will
treat it just like any other object, except it will not garbage collect
it.


    Private Shared mCurrentUser As CurrentUser

    Public Shared Function Instance() As CurrentUser
        If mCurrentUser Is Nothing Then
            mCurrentUser = New CurrentUser()
            GC.SuppressFinalize(mCurrentUser)
        End If
        Instance = mCurrentUser
    End Function

-----Original Message-----
From: Manuel Costa [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 29, 2002 11:37 AM
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] singleton server problem


Hi,

Is there a limit for the number of simultaneous calls to a remote object
registered as singleton? I have an application with several servers and
several clients per server. After some amount of simultaneous calls to
the servers they stop responding, blocking any client call. When a
client invokes a method it will stay blocked and if i try to debug at
the server side by putting a breakpoint in the called method, nothing
will happen. Is there any reasonable explanation for this?

Manuel

You can read messages from the Advanced DOTNET archive, unsubscribe from
Advanced DOTNET, or subscribe to other DevelopMentor lists at
http://discuss.develop.com.

You can read messages from the Advanced DOTNET archive, unsubscribe from
Advanced DOTNET, or subscribe to other DevelopMentor lists at
http://discuss.develop.com.

You can read messages from the Advanced DOTNET archive, unsubscribe from
Advanced DOTNET, or subscribe to other DevelopMentor lists at
http://discuss.develop.com.

You can read messages from the Advanced DOTNET archive, unsubscribe from
Advanced DOTNET, or subscribe to other DevelopMentor lists at
http://discuss.develop.com.

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to