473,396 Members | 1,982 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,396 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 1715
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.