2D Toolkit Forum
2D Toolkit => Support => Topic started by: tetrigon on January 20, 2014, 02:39:09 am
-
Perhaps this is an issue within Unity itself, but I'd like to bring to attention that there is a memory leak as of Unity 4.3.3 and 2D Toolkit 2.3.3. I receive this error often after a few hours of use with a project that contains heavy amounts of tk2D goodness.
"FATAL Crash
Could not allocate memory: System out of memory!
Trying to allocate: 5592408B with 32 alignment. MemoryLabel: Texture
Allocation happend at: Line:391 in /Applications/buildAgent/work/d3d49558e4d408f4/Runtime/Graphics/Texture2D.cpp
Memory overview
[ ALLOC_DEFAULT ] used: 60295103B | peak: 0B | reserved: 130215501B
[ ALLOC_GFX ] used: 1184621873B | peak: 0B | reserved: 1263534464B
[ ALLOC_CACHEOBJECTS ] used: 3457320B | peak: 0B | reserved: 10485760B
[ ALLOC_TYPETREE ] used: 4998295B | peak: 0B | reserved: 17825792B
[ ALLOC_PROFILER ] used: 163461B | peak: 0B | reserved: 8388608B
UnityEngine.Texture2D:LoadImage(Byte[])
tk2dSpriteCollectionData:Init() (at Assets/TK2DROOT/tk2d/Code/Sprites/tk2dSpriteCollectionData.cs:525)
tk2dSpriteCollectionData:get_inst() (at Assets/TK2DROOT/tk2d/Code/Sprites/tk2dSpriteCollectionData.cs:488)
tk2dBaseSprite:Awake() (at Assets/TK2DROOT/tk2d/Code/Sprites/tk2dBaseSprite.cs:901)
tk2dSprite:Awake() (at Assets/TK2DROOT/tk2d/Code/Sprites/tk2dSprite.cs:21)"
Perhaps this can be checked to see if this is something an update to 2D Toolkit can't fix. Thanks for the great product and support!
-
Are you using the png atlas feature? That does leak memory and is a known issue. Have you tried enabling the unload manager? tk2dEditorSpriteDataUnloader.cs, uncomment the first line
-
Ah, I see. Yes, that is indeed the case. I was unaware that png's leaked. I'll give the unload manager a shot, but I think it should be fine to just switch the atlas settings to Unity Texture unless there's some other latent gotcha I'm unaware of (other than the in-editor's larger content size note).
Thanks for the heads up!
-
I am getting the crash now in Unity 4.5 with out any PNG atlases. I am using 4x2x1x platforms and I don't get a crash when I remove the tk2d folder from the resources folder. I know that does not solve my problem but it does show me where it is. Any idea?
-
png atlases & platforms use the same path. It could be that unity has changed how things get unloaded and/or the memory management. I'll have a look at some point.
-
Please do. From further investigation, it just seems like the total texture memory that seems to be an issue. When I move some of my textures to PNG, it helps and I can build (iOS) but when I add more atlases, the problem re-appears. are you doing any post processing on those textures at all? can you direct me to a class that I can poke a round in and see if I can fix?
-
We dont do any post processing on the textures - just save them as PNG and get unity to reload. I also dont seem to be able to reproduce this. My guess is you're very close to the limit and some change in unity 4.5 has pushed it just over?
-
I dont think I am near the limit because I have 16GB ram. You never know though. I think it has to do with the linkage system. (a scriptable object in the resources folder that points to a texture). I way that because when I tried to do that very thing I had the issue again. BUT, when I built not using the any Unity editor build buttons, just the build command, I had no problems. Ill update if this changes. I think it has to do with the editor thread. So if any one else is suffering from the same issue, make a custom build panel and build from there.
UPDATE
Scratch that, still crashing
-
16GB of ram makes no difference. Unity is a 32 bit application (still), so it can use about 3.5GB of memory tops before it blows up.