no instantiate/destroy but GC is still called!

Hi, i have implemented the poolmanager plugin in my android game and have 0 instantiate/destroy commands during gameplay, yet im always getting garbage collector calls once in awhile in the logcat internal profiler.

I’m suspecting it might have something to do with the sound, but i don’t understand why, any object that uses audio has it’s own sound source and the clips are referenced to variables on that object.

should i instead create 1 single universal AUDIO object that contains all my clips in variables and just play them by reference?

or maybe use poolmanager to create a pool of audiosources with any clip that i need and have object spawn whatever source they need at their location?

I can’t think of what else might be causing the garbage collector to be called.

GC works on every memory location that you no longer have a reference too. Instantiate and destroy are just called out as they are heavy producers of garbage. GC problems are typically noticeable in terms of occasional ‘stutters’ while playing the game. If no noticeable stutters then GC is not worth worrying about. The profiler will indicate the scripts that are producing the garbage, if you are overly concerned.

If its a finished game with performance problems then worry about GC. If its a half produced game that cannot be finished because of performance problems then worry about GC.

If your game has no performance issues, or you are worried that GC might be a problem later, then forget about it. Pre-optimisation generally causes more problems then it solves.