Re: [twsocket] bug in TCustomWSocket? - 100% cpu; continues calls to OnDataAvailable while no data was received
Merijn Bosma wrote: Hello, Yesterday evening we've found out that this problem still occurs, even with wsoNoReceiveLoop set. The symptoms are the same: - OnDataAvailable event is triggered continuously (close to 14000 times per second) - ReceiveStr() is called every time, returning no data - Error is always 0 in the events - The event keeps being triggered until we shut down the application. This is not a high speed stream, we sent only control data, so approx up to 100 bytes every few seconds. I'm I doing something stupid or is there something else going wrong here? If it's not me, is there any way for to determine whether this is a problem with ICS, or with the Windows call stack itself? Francois PIETTE wrote: One possible explanation were that anytime OnDataAvailable returns, just a few _new_ bytes are available in winsock buffer. Could be possible due to the background thread winsock creates internally with non-blocking sockets, though I'm not aware of how winsock works under the hood. When in this situation, we got a few hundred calls a second, for an unlimited time, where normally it's one every few seconds. I agree with you, it could be a possible cause, but very unlikely. Do you receive data each time you call ReceiveStr ? If yes, then probably you have a fast network, and your application becomes CPU bound. That's the thing, I don't receive any data. At least not using ReceiveStr() btw: Since you don't use line mode, I strongly suggest you avoid ReceiveStr and instead use Receive with a fixed buffer. Calling ReceiveStr will force the runtime to create new string and copy data into it, and probably youthen copy data elsewhere for processing. All this is very CPU intensive. The best way to design a high performance application is to use a fixed buffer (which may be dynamically allocated but not each time you receive data). And use the buffer as close as possible of the processing each time you copy data, each time you consume CPU and memory for nothing. -- [EMAIL PROTECTED] The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] bug in TCustomWSocket? - 100% cpu; continues calls to OnDataAvailable while no data was received
Hi, - OnDataAvailable event is triggered continuously (close to 14000 times per second) Do you call the message pump from OnDataAvailable, directly or indirectly (i.e. Application.ProcessMessages, any Showmessage() or a VCL-dialog)? -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html Merijn Bosma wrote: Merijn Bosma wrote: Hello, Yesterday evening we've found out that this problem still occurs, even with wsoNoReceiveLoop set. The symptoms are the same: - OnDataAvailable event is triggered continuously (close to 14000 times per second) - ReceiveStr() is called every time, returning no data - Error is always 0 in the events - The event keeps being triggered until we shut down the application. This is not a high speed stream, we sent only control data, so approx up to 100 bytes every few seconds. I'm I doing something stupid or is there something else going wrong here? If it's not me, is there any way for to determine whether this is a problem with ICS, or with the Windows call stack itself? Francois PIETTE wrote: One possible explanation were that anytime OnDataAvailable returns, just a few _new_ bytes are available in winsock buffer. Could be possible due to the background thread winsock creates internally with non-blocking sockets, though I'm not aware of how winsock works under the hood. When in this situation, we got a few hundred calls a second, for an unlimited time, where normally it's one every few seconds. I agree with you, it could be a possible cause, but very unlikely. Do you receive data each time you call ReceiveStr ? If yes, then probably you have a fast network, and your application becomes CPU bound. That's the thing, I don't receive any data. At least not using ReceiveStr() btw: Since you don't use line mode, I strongly suggest you avoid ReceiveStr and instead use Receive with a fixed buffer. Calling ReceiveStr will force the runtime to create new string and copy data into it, and probably youthen copy data elsewhere for processing. All this is very CPU intensive. The best way to design a high performance application is to use a fixed buffer (which may be dynamically allocated but not each time you receive data). And use the buffer as close as possible of the processing each time you copy data, each time you consume CPU and memory for nothing. -- [EMAIL PROTECTED] The author of the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] bug in TCustomWSocket? - 100% cpu; continues calls to OnDataAvailable while no data was received
Arno Garrels wrote: Hi, - OnDataAvailable event is triggered continuously (close to 14000 times per second) Do you call the message pump from OnDataAvailable, directly or indirectly (i.e. Application.ProcessMessages, any Showmessage() or a VCL-dialog)? I'm digging through code right now just to be sure. In case I am, could that explain this behavior? I'm not calling the message pump when I'm receiving no data, so shouldn't that break the loop if it was there? -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] bug in TCustomWSocket? - 100% cpu; continues calls to OnDataAvailable while no data was received
Merijn Bosma wrote: Arno Garrels wrote: Hi, - OnDataAvailable event is triggered continuously (close to 14000 times per second) Do you call the message pump from OnDataAvailable, directly or indirectly (i.e. Application.ProcessMessages, any Showmessage() or a VCL-dialog)? I'm digging through code right now just to be sure. In case I am, could that explain this behavior? I think so. I'm not calling the message pump when I'm receiving no data, so shouldn't that break the loop if it was there? The event handler may be reentered, so don't call the message pump from there. If you want i.e. display a dialog you could post a custom message and from its message handler pop up the dialog. -- Arno Garrels [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be