我有一个在iOS,Android和Windows Phone上运行的Unity3D内置的3D无尽亚军游戏。Unity3d巨大的内存使用纹理
它正常工作在Windows Phone上使用1014MB内存及以上,但在它一旦它开始崩溃(在文章底部看到从Visual Studio错误消息)。
看着探查器,我可以看到纹理的内存使用率非常高,知道我在Lumia 520上最多只能获得180MB RAM,例如,我可以从探查器看到纹理占用359MB ,甚至在第八个分辨率(下面的截图),他们仍然占用232MB!我已经经历了每一个纹理,使它尽可能小并且被压缩,我在这里做了些什么错事?我怎样才能更多地了解什么纹理是问题?
我通常在游戏中帮助帧速率开始预加载的所有程序级别的元素到内存中,一旦你正在运行,但我把这个完全关闭甚至当内存使用不受影响。
任何推向正确的方向将非常有帮助,谢谢!
Visual Studio的崩溃控制台日志转储:
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: DefaultDomain): Loaded 'C:\windows\system32\mscorlib.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Windows.RuntimeHost.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Windows.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Net.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Xml.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\Data\Programs\{DFE540D3-80C1-4CFF-BFCA-CE252BC4EECE}\Install\EndlessRunner.DLL'. Symbols loaded.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\Microsoft.Phone.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\Microsoft.Phone.Interop.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\Data\Programs\{DFE540D3-80C1-4CFF-BFCA-CE252BC4EECE}\Install\WinRTBridge.DLL'. Cannot find or open the PDB file.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\Data\Programs\{DFE540D3-80C1-4CFF-BFCA-CE252BC4EECE}\Install\BridgeInterface.winmd'. Module was built without symbols.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\Data\Programs\{DFE540D3-80C1-4CFF-BFCA-CE252BC4EECE}\Install\UnityPlayer.winmd'. Module was built without symbols.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\WinMetadata\Windows.winmd'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Core.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Runtime.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Build from 'release/4.5/release' branch, version is '4.5.0f6 (fd4616464986)' (Release build).
Physical memory: 395 MB, commited memory limit: 180 MB.
PlayerConnection initialized from C:/Data/Programs/{DFE540D3-80C1-4CFF-BFCA-CE252BC4EECE}/Install/Data (debug = 0)
PlayerConnection initialized network socket : 0.0.0.0 55444
Multi-casting "[IP] 192.168.0.19 [Port] 55444 [Flags] 2 [Guid] 93005236 [EditorId] 1016877170 [Version] 1048832 [Id] WP8Player(192.168.0.19) [Debug] 0" to [225.0.0.222:54997]...
Direct3D:
Version: Direct3D 11.0 [level 9.3]
Renderer: Qualcomm Adreno 305 (WDDM v1.2) (ID=0x30303330)
Vendor: Qualcomm
VRAM: 96 MB
Initialize engine version: 4.5.0f6 (fd4616464986)
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\Data\Programs\{DFE540D3-80C1-4CFF-BFCA-CE252BC4EECE}\Install\UnityEngine.DLL'. Cannot find or open the PDB file.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\Data\Programs\{DFE540D3-80C1-4CFF-BFCA-CE252BC4EECE}\Install\Assembly-CSharp-firstpass.DLL'. Cannot find or open the PDB file.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\Data\Programs\{DFE540D3-80C1-4CFF-BFCA-CE252BC4EECE}\Install\Assembly-CSharp.DLL'. Cannot find or open the PDB file.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\Data\Programs\{DFE540D3-80C1-4CFF-BFCA-CE252BC4EECE}\Install\BFSWP8Goodies.DLL'. Cannot find or open the PDB file.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\Data\Programs\{DFE540D3-80C1-4CFF-BFCA-CE252BC4EECE}\Install\GPGSUtils.DLL'. Cannot find or open the PDB file.
'TaskHost.exe' (CLR C:\windows\system32\coreclr.dll: Silverlight AppDomain): Loaded 'C:\Data\Programs\{DFE540D3-80C1-4CFF-BFCA-CE252BC4EECE}\Install\WinRTLegacy.DLL'. Module was built without symbols.
Could not allocate memory: System out of memory!
Trying to allocate: 1398128B with 32 alignment. MemoryLabel: Texture
Allocation happend at: Line:411 in C:/BuildAgent/work/aeedb04a1292f85a/Runtime/Graphics/Texture2D.cpp
Memory overview
[ ALLOC_DEFAULT ] used: 5715133B | peak: 5715181B | reserved: 6570457B
[ ALLOC_GAMEOBJECT ] used: 43508B | peak: 43508B | reserved: 52731B
[ ALLOC_GFX ] used: 155628390B | peak: 155628390B | reserved: 155631656B
[ ALLOC_PROFILER ] used: 5028B | peak: 5028B | reserved: 12158B
Could not allocate memory: System out of memory!
Trying to allocate: 1398128B with 32 alignment. MemoryLabel: Texture
Allocation happend at: Line:411 in C:/BuildAgent/work/aeedb04a1292f85a/Runtime/Graphics/Texture2D.cpp
Memory overview
[ ALLOC_DEFAULT ] used: 5715133B | peak: 5715181B | reserved: 6570457B
[ ALLOC_GAMEOBJECT ] used: 43508B | peak: 43508B | reserved: 52731B
[ ALLOC_GFX ] used: 155628390B | peak: 155628390B | reserved: 155631656B
[ ALLOC_PROFILER ] used: 5028B | peak: 5028B | reserved: 12158B
(Filename: C:/BuildAgent/work/aeedb04a1292f85a/Runtime/Allocator/MemoryManager.cpp Line: 909)
The program '[2540] TaskHost.exe' has exited with code -2147483645 (0x80000003).
好的,真正的问题是:你有多少纹理,它们的尺寸是多少?它们是否被压缩并计算纹理记录报告的纹理内存使用是否与计算相匹配?提示,对于未压缩纹理,字节大小为:width * height *(color bit depth/8)= bytes。例如一个1024x1024的非压缩纹理占用4MB的内存。如果你把它降低到16色bpp,它会减少一半。 – LearnCocos2D 2014-09-25 09:34:51