Quote:
Originally Posted by AlexanderTheOK
That explains the 250ms lag spikes I've been seeing every once in a while. Any standard way to mitigate this?
|
1) Use a language implementation whose runtime doesn't do garbage collection (this may or may not exist for your language of choice)
2) Use a specially-tuned "low latency" garbage collector implementation (you probably need to test that it actually works properly for your application's usage pattern though)
3) Avoid heap allocation (to the extent that you can - just running the required libraries may produce a considerable amount of garbage, you'd need to check this)
You might also consider manually triggering a collection frequently so that less work is done each time it runs. For example, you could have it so that every time the robot got a packet from the driver station it would run an iteration of the control code and then do a GC. You would have to see how long the pause is to see if that would be acceptable.