[CoMoDev] Re: Garbage collection

  • From: "Andrei P." <andreip@xxxxxxxxxxxxxxxxx>
  • To: <comodev@xxxxxxxxxxxxx>
  • Date: Wed, 17 Aug 2005 11:28:03 -0600


When would you switch to StringBuilder, concatenating 5, or 10, or how many
strings? What's the rule of thumb for CF?

Would you recommend to run GC in certain conditions? I believe I'd better
have 10 one-second delays, than one ten-seconds one.



-----Original Message-----
From: comodev-bounce@xxxxxxxxxxxxx [mailto:comodev-bounce@xxxxxxxxxxxxx] On
Behalf Of Darren Shaffer
Sent: Wednesday, August 17, 2005 11:17 AM
To: comodev@xxxxxxxxxxxxx
Subject: [CoMoDev] Re: Garbage collection

Absolutely you need to be using StringBuilder for string concatenation
in .NET CF - strings are immutable in .NET and you are right, you are
burdening the GC with mark & sweep on hundres of strings if I understand
What you're doing.  I still wouldn't rule out that you've over-done the 
threading in your app, even if it is technically correct.

Keep things simple with the Compact Framework and you'll end up
better off than engineering in too much parallelism.  The problem is
not the XScale - I promise.

Darren Shaffer
Principal Software Architect
Connected Innovation
Microsoft .NET Compact Framework MVP
(303) 886-1932

-----Original Message-----
From: comodev-bounce@xxxxxxxxxxxxx [mailto:comodev-bounce@xxxxxxxxxxxxx] On
Behalf Of Andrei P.
Sent: Wednesday, August 17, 2005 11:01 AM
To: comodev@xxxxxxxxxxxxx
Subject: [CoMoDev] Re: Garbage collection

Well, I haven't seen a minute delay as well. That's what I've been told.
Could be just a user's impression. But I've seen about 10 seconds delays a
few times in different places. So it's definitely not a "dead" lock, because
it recovers without any exception. 
I'm pretty sure I have a good threading with proper synchronization. I
excluded all the probable reasons except the next two:
1. The hardware (RFID reader) is eating CPU cycles. It's Intermec device.
You may remember what Kevin Price told about his experience with Intermec in
his RFID presentation - their hardware is not reliable at all and AccuCode
stopped using them completely.
2. GC. My primary concern is CF's algorithm of ended threads disposing. Also
I parse socket responses, creating more than a hundred of short strings
every time, that could add to the burden. That's where I thought I may need
to run GC. Or change the algorithm.
BTW, do you use StringBuider or whatever name is in order to not overload
the heap? What is the rule of thumb to switch from "<string> + <string> +
.." to StringBuilder?



-----Original Message-----
From: comodev-bounce@xxxxxxxxxxxxx [mailto:comodev-bounce@xxxxxxxxxxxxx] On
Behalf Of David Beers
Sent: Wednesday, August 17, 2005 10:31 AM
To: dick_grier Grier
Subject: [CoMoDev] Re: Garbage collection

Andrei, for what it's worth I've never seen the kind of delay you're talking
about just from garbage collection (in Java or .NET CF).  I don't think
trying to "help" the GC by invoking it directly at a certain time is
generally a good idea.  I never do it.  Given all the multithreading you're
doing I agree with Dick that maybe you should be looking for possible

David Beers
Pikesoft Mobile Computing
Skype ID: pikesoft

On Tue, 16 Aug 2005 18:40:25 -0600, dick_grier Grier wrote:
> Hi Andrei,
> However could it be so bad that 400 mHz XScale
> hangs for a minute?
> <<
> I would not think so.  I haven't seen anything like this, but my 
have been smaller than the one that you have described.
> This sounds more like some sort of dead-lock.  Do any of your worker
threads share data or depend on shared objects?  Perhaps something is going
on there?
> Dick
> Richard Grier (Microsoft MVP - Visual Basic)
> Hard & Software
> 12962 West Louisiana Avenue
> Lakewood, CO  80228
> 303-986-2179 (voice)
> 303-593-9315 (fax)
> Author of Visual Basic Programmer's Guide to Serial Communications, 
Edition ISBN 1-890422-28-2 (391 pages) published July 2004. For faster
service, contact the publisher at http://www.mabry.com/vbpgser4.

Other related posts: