Author Topic: Garbage collection  (Read 799 times)

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Garbage collection
« on: September 29, 2012, 08:39:25 pm »
How can I optimize code for Android garbage collection? GB takes every 5 seconds about 70ms...
« Last Edit: October 02, 2012, 12:36:09 pm by Thomas. »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Garbage collection
« Reply #1 on: September 29, 2012, 08:50:21 pm »
Create less garbage... ;)

Regarding jPCT, make sure that you are using the methods that take the return value as parameter where possible (like getTranslation(<SimpleVector>) instead of getTranslation()).

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Garbage collection
« Reply #2 on: October 02, 2012, 12:35:42 pm »
Thanks, these methods helped ;) I checked whole my code and there also were a lot of garbage. GC is called every 7 seconds, now. My measuring shows, that the largest memory allocation causes calling method checkCollisionEllipsoid(). Is there any possibility for optimization this method?
« Last Edit: October 02, 2012, 12:38:35 pm by Thomas. »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: Garbage collection
« Reply #3 on: October 02, 2012, 12:51:36 pm »
No. Object creation of this method has already been reduced to the bare minumum. You can avoid some additional object creation if you don't use collision listeners, but that's about it.