0

i'm trying to write a realtime application (with physical interaction) with c# language. Globaly it work fine, but sometimes my criitical section has to be late and this is not pretty good. i'll suggest my GC is involved in first time.

i use actually default parameters c# (GC is active, prog is not pre-jitted, i don't use marshall, etc).

can i disable momentarily the GC activities (i know it work in async parallel thread) for my critical code section or maybe something like it ?

or should i to says to my GC to do not manage my critical section ?

i'm open to any request and remarks thanks !

edit : my prog is always on real-time.

Florian J
  • 59
  • 8

1 Answers1

0

This question might help you. Prevent .NET Garbage collection for short period of time Also, what makes you think that GC is responsible for the lateness? I also would like to say, that you might want to use structures, since they are stored in stack, so they are not affected by GC and generally are faster.

Community
  • 1
  • 1
netaholic
  • 1,345
  • 10
  • 22
  • i doesn't see this article but i was seen that [MSDN low latency mode](https://msdn.microsoft.com/en-us/library/bb384202.aspx). i know GC is faster but went is was called he stop all thread, you can see that [here](https://msdn.microsoft.com/fr-fr/library/ee787088%28v=vs.110%29.aspx). it's possible my problem is different and GC is not in charge. – Florian J Aug 14 '15 at 10:00
  • Well, I've provided you with answer on how to suspend GC. If you want the community to find the origin of you problem you should post code examples – netaholic Aug 14 '15 at 10:03
  • 1
    @FlorianJ Note that in .NET 4.6 they added two new methods for this: [`GC.TryStartNoGCRegion`](https://msdn.microsoft.com/en-us/library/system.gc.trystartnogcregion.aspx) and [`GC.EndNoGCRegion`](https://msdn.microsoft.com/en-us/library/system.gc.endnogcregion.aspx) – xanatos Aug 14 '15 at 10:10
  • thanks for your answer, i can't post an exemple of code now, but can i have mre precision to how to do this ? The critical section should be mandatory into a try-finally ? how long the GC was correctly setted to low latency mode ? i don't use any struc on my app – Florian J Aug 14 '15 at 10:16
  • oh well @xanatos, don't know this, i'll looking for more information to .NET 4.6, thanks ! – Florian J Aug 14 '15 at 10:18