• RuntimesUnity
  • How can I cleanly unload Spine caches during Unity runtime?

How can I cleanly unload Spine caches during Unity runtime? After unloading, I noticed using the Memory Profiler that many Spine-related data are still in memory.
The code I'm using is:
void UnloadSkeleton () {
Resources.UnloadAsset(skeletonDataAsset);
skeletonDataAsset = null;
Destroy(createdSkeletonObject);
Resources.UnloadUnusedAssets();
}

I used the Memory Profiler to capture two frames, one before and one after unloading, and noticed that there are still Spine data present in the resources common to both frames. How can I completely and cleanly unload these?
As seen in the image below

Related Discussions
...

@JoyBSun SkeletonDataAsset is not cached. If you hold no more references to a SkeletonDataAsset or SkeletonData, then the respective memory should be freed as normal. Note that e.g. AnimationReferenceAsset and similar assets may reference a SkeletonDataAsset as well, and access SkeletonData once and then hold the reference until destroyed.

Also, any components like SkeletonAnimation that are depending on SkeletonDataAsset are loading the data once in form of SkeletonData and then keep this loaded data around (keep a reference to it) until reset or destroyed. SkeletonData includes all relevant skeleton data such as Bones, Animations, etc.

Regarding your code above: it only destroys a skeletonDataAsset, but if you've done nothing else, a SkeletonAnimation GameObject will still hold a reference to the SkeletonData that it initially loaded. Since you showed only a small section of code, too much context is missing to guess what else you did to remove any references to skeleton data.