Quote:
Originally Posted by Jared
We don't have any mentors on our team who are familiar with Java or are programmers, so I've been unable to really figure out why System.gc() helps with loop timing.
|
1) Any object allocations (using the 'new' operator) cannot be assumed to be constant time, as it is basically just mallocing. System.gc is probably just clearing out a portion of memory large enough to not cause the memory allocator to have to look very far to find a spot. We allocate very infrequently and never in control loops to help with this issue.
2) The garbage collector probably won't need to run much within 15 seconds after you explicitly call it. This could be eating CPU.
The real answer is probably to use C/C++.
:-/