libgdx/libgdx — pull request #1758 by ntherning (2014-04-24 12:02:46+00:00)
Title: Less GC in RoboVM iOS backend

The ObjC-Java bridge in RoboVM will create a Java peer the first time an ObjC instance crosses the ObjC<->Java boundary. This peer will be associated (using the `objc_setAssociatedObject()` in the Objective-C runtime) with the ObjC instance and the next time the same ObjC instance crosses the boundary the same peer will be used on the Java side. The Java peer will retain the ObjC instance until the Java peer is GCed.

For frequently created, short-lived objects (like `UIAcceleration` or `UITouch` instances) this can lead to performance problems. The Java peers quickly become unreachable but cannot be reclaimed until the next GC and the corresponding ObjC instances will not be deallocated until the Java peer is GCed.

This patch uses a single `UITouch` and a single `UIAcceleration` instead of creating new ones on each touch/acceleration event. These events are handled single-threaded so reusing the same instance should not be a problem. As far as I can see this significantly decreases the garbage generated and thus the frequency of GC pauses during touch and acceleration events.