Garbage Collection Insight

Few questions

  1. Is it possible to see when GC occurs on its own?
  2. Is it possible to see what exactly the GC is finalizing?
  3. I imagine it is also compacting the heap?
  4. Will the UI thread (once I implement) cause undesired GC? If so, is there a way to prevent this?

I have to send CAN packets at a very precise timing structure (250us), and GC is causing the can thread to become paused (I think) for approximately 150ms which is causing the DUT to fail.

Thanks in advance.

Memory Management Debug.EnableGCMessages(true)

You can do this before you time critical task

GC.Collect();

GC.WaitForPendingFinalizers();

Thanks Gus, I figured this was the only option. Doing this before each block in my large data set slows things down overall, but better than the failure.

1 Like