www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Thomas. on September 29, 2012, 08:39:25 pm

Title: Garbage collection
Post by: Thomas. on September 29, 2012, 08:39:25 pm
How can I optimize code for Android garbage collection? GB takes every 5 seconds about 70ms...
Title: Re: Garbage collection
Post by: EgonOlsen 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()).
Title: Re: Garbage collection
Post by: Thomas. 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?
Title: Re: Garbage collection
Post by: EgonOlsen 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.