1

I used to read various blogs and recommendations that pooling normal Java objects (not objects like connections or the like) does not improve and may actually decrease the performance, being an anti-pattern. However this is much less common to hear about the Android platform, and many gaming libraries, for instance, provide classes for reusing existing objects. Now I read that object pooling reduces the number of the garbage collection cycles, improving the performance.

How is a desktop computer so different from the mobile device that a different development pattern is recommended? The probable answers could be

  • Object pooling also makes desktop application run better
  • Object pooling does not actually help with Android applications
  • There are some important differences between Java SE and Android JVM.
  • Object pooling is not recommended for the desktop because using it brings less benefits than it brings for mobile applications (but does, so may be good in some cases?)
Audrius Meškauskas
  • 20,936
  • 12
  • 75
  • 93

1 Answers1

1

Android is different from oracle Java and what you ask is due to the underlying virtual machine having very different characteristics.

Essentially the Hotspot JVM uses lots of memory to gain speed. Android hardware seldom allows that so objects are much more expensive to make on android than in oracle java (and apparently reflection is slow too).

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347