Hello Guest

Author Topic: Memory Leak  (Read 9164 times)

tetrigon

  • Newbie
  • *
  • Posts: 2
    • View Profile
Memory Leak
« 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.

Quote
"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!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Memory Leak
« Reply #1 on: January 20, 2014, 11:55:35 am »
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

tetrigon

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Memory Leak
« Reply #2 on: January 20, 2014, 09:05:16 pm »
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!

collectivemass

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Memory Leak
« Reply #3 on: May 28, 2014, 02:51:09 am »
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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Memory Leak
« Reply #4 on: May 28, 2014, 11:16:22 am »
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.

collectivemass

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Memory Leak
« Reply #5 on: June 04, 2014, 10:59:09 pm »
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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Memory Leak
« Reply #6 on: June 05, 2014, 12:12:02 am »
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?

collectivemass

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Memory Leak
« Reply #7 on: July 04, 2014, 01:18:09 am »
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
« Last Edit: July 04, 2014, 01:41:24 am by collectivemass »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Memory Leak
« Reply #8 on: July 04, 2014, 11:31:39 am »
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.