我有一個在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