Main Site Documentation

GC takes over 2s to complete


#1

GC takes over 2 seconds to complete on Cobra II (4.3.4) when VS debugger is not attached. When it is attached, it takes few milliseconds. Why? Two seconds is really a lot of time during which board is not responsive.

Sample code:

Dim led As Boolean
Dim c As Integer

While True
	led = Not led
	Mainboard.SetDebugLED(led)
	Thread.Sleep(100)
	c += 1
	If c = 30 Then
		c = 0
		Debug.GC(True)
	End If
End While

Take a look how LED stops flashing for 2+ seconds while VS debugger is not attached.


#2

I believe it’s not GC, but the good old USB debug output bug.


#3

debug using MFDeploy instead of VS.


#4

I did a quick test. If I half-plug USB cable (so that only power pins are connected), I get no hangs. What a nasty bug… Is anyone working on it?


#5

I do not see how this could be possible! But we will test on our end to double check.


#6

It’s more than possible. There’s lots of chat about this bug in the forum, it’s an ancient one.


#7

It’s even on Codeplex:

http://netmf.codeplex.com/workitem/2179


#8

I am talking about half plug USB cable, very much not possible!


#9

Oh, ok. My bad.


#10

@ Gus - why not? The power tracks are longer than the data tracks.


#11

Yes :slight_smile:

That is a quick and dirty way to test what will happen if only 5V power line is connected while data lines are not connected.


#12

@ iamin - Looks like it is that bug on CodePlex. I was able to reproduce it, but when I called Debug.EnableGCMessages(false) before the loop it went away.


#13

Ok so the bug is in debug.print in general where things run slow when nothing is attached. I wonder if we can somehow cheat and make this work on the driver level.


#14

… And half plugging the usb cable week not solve this :slight_smile:


#15

Yeah, [em]Debug.EnableGCMessages(false)[/em] helps to hide this issue.

Here is another example. Blinking rate is slowed down by a factor of ~2 when debugger is not attached, but board is powered from USB cable (fully plugged).

Dim led As Boolean

While True
	led = Not led
	Mainboard.SetDebugLED(led)
	Thread.Sleep(100)
	Debug.Print("Some random message here to test how it will work...")
End While

Would be nice.


#16

Just to make it super-clear:

  1. No Debug.Print() -> no problems;
  2. Debug.Prints -> USB attached -> Debugger (or Fez Config) attached -> no problems;
  3. Debug.Prints -> USB attached -> Debugger (or Fez Config) not attached -> problems!!!;
  4. Debug.Prints -> USB not attached -> no problems;

#17