472,992 Members | 3,687 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Don't understand keepalive...

Hi!
I've got a problem with the GC.keepalive function,
as used in the examples at
http://msdn2.microsoft.com/en-US/lib...keepalive.aspx
..
There they have a class "Example", construct it and call a method,
during which it may get collected.
Why would it get collected, before the last method call ends?
Is this a bug on the GC or is there a resson for it?

Lots of greetings!
Volker
--
For email replies, please substitute the obvious.
May 22 '06 #1
2 1691
if a object is passed into a native method the GC cannot track it. therefore
you have to use keepalive to make sure it is not collected until the method
returns.

--
"Volker Hetzer" <fi****************@ieee.org> schrieb im Newsbeitrag
news:e4**********@nntp.fujitsu-siemens.com...
Hi!
I've got a problem with the GC.keepalive function,
as used in the examples at
http://msdn2.microsoft.com/en-US/lib...keepalive.aspx
.
There they have a class "Example", construct it and call a method,
during which it may get collected.
Why would it get collected, before the last method call ends?
Is this a bug on the GC or is there a resson for it?

Lots of greetings!
Volker
--
For email replies, please substitute the obvious.

May 22 '06 #2
cody schrieb:
if a object is passed into a native method the GC cannot track it. therefore
you have to use keepalive to make sure it is not collected until the method
returns.

Yes, I have no problem accepting that.
However, the way I read the documentation (hopefully wrongly) there's some
way the garbage collector can try to reclaim an object while it is involved
in an actual method call and no unmanaged code is involved in any way.

The example in http://msdn2.microsoft.com/en-US/lib...keepalive.aspx
appears to be indicating that there is a nonzero possibility that an object
(ex in this case) gets collected between those two lines of code
Dim ex As New Example()
Dim res As Byte() = ex.Hash
..

Lots of Greetings!
Volker
--
For email replies, please substitute the obvious.
May 22 '06 #3

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

Similar topics

0
by: unni | last post by:
Whats The Other Option For Keeping Connection Alive ? Since Http.keepalive = True Is Not Working In The Code. Is There Any Thing More Required Along With The Http.keepalive = True
1
by: Cliff Harris | last post by:
I am trying to automate a series of form posts on a website. This site requires that my session be kept alive through successive posts (it basically tracks me by a sessionid, and if I get a new...
0
by: Kevin | last post by:
Hi, How can you set up the timeout values of the KeepAlive Socket option like you do using WSAIoctl and SIO_KEEPALIVE_VALS using C++ ? Searching about this I found several post of people using...
4
by: Kalpesh Modha | last post by:
Hello. I sometimes get this error message "An existing connection was forcibly closed by the remote host" for no reason what so ever in my program. I was wondering keepalives would help in this...
0
by: Ziphyre | last post by:
Hi, I can't send 'Connection: Keep-Alive' property in the second connection of my HttpWebRequest. Suppose: HttpWebRequest hreq = ..... hreq.KeepAlive = true; HttpWebResponse hresp =...
0
by: Greg | last post by:
I have a problem with KeepAlives. I need to use them for crawling a secure server, but if I crawl too long the application memory keeps increasing and doesn't decrease. After lots of testing,...
1
by: okaminer | last post by:
Hi This is for the experts I have override the GetWebRequest method and set the keepalive property to false in order to overcome a certain in .NET web service problem. My problem now is that...
3
by: Ryan Liu | last post by:
Hi, I use Server: Use an endless thread to lisiten to clients requests: while(true) { TcpClient client = myListener.AcceptTcpClient();
1
by: semedao | last post by:
Hi, I want to implement keepalive on connected socket between 2 machines , that can be behind NAT. I saw the SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, 1) and the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.