reddy36996 đã viếtIf it's a memory issue, it should happen across all devices as long as we keep repeating calls to GetRepackedSkin()
I would at least suspect that the issue could be memory related, as the log file that you posted lists "<gsl_memory_alloc_pure:2203>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed"
124 times out of 237 lines.
Regarding that it should happen on all devices: I would not assume this, what if Unity's asset cleanup kicks in regularly before it runs out of memory on some devices, and too late on others?
reddy36996 đã viếtSpine is already providing that functionality in AtlasUtilities.ClearCache(), we tried calling it every time
No, your assumption is incorrect. AtlasUtilities.ClearCache()
clears cached regions that are produced by AtlasRegion.ToTexture()
calls, but not repacked atlas textures. They are not cached in Spine structures but left in responsibility of the user.
reddy36996 đã viếtAdding Resources.UnloadUnusedAssets makes some difference, as Destroy() doesn't release memory until that asset is unloaded from memory.
What exactly do you mean by until that asset is unloaded from memory.
? If you mean unloading via Resources.UnloadAsset
, this is not intended for a resource created with new
.
Anyway, you should of course not hold any references to it any longer, but I assume that you don't.
The basic pattern in Unity is (or was) that every new Texture2D()
call should be balanced by a matching Destroy()
call. At least it was like this many years ago, now documentation is for some reason not listing it any more. Perhaps clearing any references to it and waiting for GC / Unity's asset cleanup is the recommended way now?
reddy36996 đã viết
Also we can't use Resources.UnloadUnusedAssets in our project even if it had worked bcoz Whenever it runs on main thread, game gets laggy, specially when we do this calls very frequently.
This is why I recommended the Destroy();
call.
Perhaps this is related to a Unity bug with your used version in combination with some devices? At least this seems to have happend in the past:
https://answers.unity.com/questions/893772/texture2d-generation-causing-memory-leak-system-ou.html
reddy36996 đã viếtWith this change, sample project is not crashing anymore but it had no effect in our project.
Does the sample scene stop crashing when you are calling Destroy()
only and not Resources.UnloadUnusedAssets
?
Are you perhaps having some other calls like new Texture()
that are not balanced with coresponding Destroy()
/ cleanup code? Where exactly does your own project crash, what is the scenario there? Did you analyse memory usage of the device that was crashing?
One thing I forgot to ask:
Which version of the spine-unity runtime (name of the unitypackage) are you using?