List
ImageTrackableBehaviour garbage collection
Posted Date: 2018-10-29 17:05     Edited Date: 2018-11-01 7:02     Writer: inchkiev

So, it's not the problem, but i want you to explain to me something. I changed ImageTrackableBehaviour script so it won't find objects every frame, and save some perfomance that way. Because now, it generates 2 mb of garbage (a lot of renderers are in the scene (low poly though)). So i changed it the way it only finds components one time and reuses cashed values. Okey, so i started Unity scene, and nothing happened. I restarted, and nothing. Next i undone all changes to the script and started again -- the same result. And i realized, that even in editor all my objecrs were gone. Altough they were in hierarchy they couldn't be found in scene. Thanks god i made backup few minutes before changing script, and everything returned to normal after i reverted version. So, can you please explain what happend, maybe i did something wrong. And can you give me some tips on how to decrease garbage collection in ImageTrackableBehaviour? It ruins performance.

Posted Date: 2018-10-30 2:15     Edited Date: 2018-10-30 2:15     Writer: slkim

1. do you want to load ImageTrackableBehaviour before ARScene?

2. if you don't want to destroy ImageTrackableBehaviour, see Object.DontDestroyOnLoad function.

3. or use Singleton pattern.

Posted Date: 2018-10-30 8:38     Edited Date: 2018-10-30 8:38     Writer: inchkiev

It has 2 methods:

public override void OnTrackSuccess(string id, string name, Matrix4x4 poseMatrix);

public override void OnTrackFail();

And every frame it is called in ImageTrackerSample and does searching for components:

Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true);
Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);
Graphic[] graphicComponents = GetComponentsInChildren<Graphic>(true);

I wanted to do searching beforehand. But as i said something went completely wrong.

 

Posted Date: 2018-11-01 7:02     Edited Date: 2018-11-01 7:02     Writer: slkim

https://github.com/maxstdev/MaxstARSDK_Unity_Sample

see above Code. 

use NoImageTrackerble Scene. in ExtraSample/Scenes