Resources.UnloadUnusedAssets(); crashes Windows Phone

I have an issue where if I call Resources.UnloadUnusedAssets(); after about 60 seconds into my gameplay it will crash the game. I am not loading any new assets during this time it is just objects being moved around.

Has anyone else noticed this?

I called Resources.UnloadUnusedAssets(); right before the gameplay started btw so it wouldn’t be anything from the initial loading.

This sounds like a serious bug. Did you check the log on the phone?

It’s happening the same thing to our game.
I’m porting my game to Windows phone and it’s getting this error right after I do Resources.UnloadAssets:

Unloading 0 unused Assets to reduce memory usage. Loaded Objects now: 860. Operation took 74.855850 ms.

System memory in use: 3.3 MB.

Exception: Incorrect hashcode
Type: System.Exception
Module:
InnerException:
AdditionalInfo:

(Filename: C:/BuildAgent/work/d63dfc6385190b60/Runtime/Scripting/WinRTUtility.cpp Line: 88)

A first chance exception of type ‘System.NullReferenceException’ occurred in WinRTBridge.DLL
A first chance exception of type ‘System.Runtime.InteropServices.SEHException’ occurred in WinRTBridge.DLL
Exception: External component has thrown an exception.
Type: System.Runtime.InteropServices.SEHException
Module: WinRTBridge
InnerException:
AdditionalInfo:
at WinRTBridge.SerializationWeaverReader.ReadUnityEngineObject()
at LevelMap.Unity_Deserialize()
at UnityEngine.IUnitySerializable.$Invoke0(Int64 instance, Int64* args)
at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)

(Filename: C:/BuildAgent/work/d63dfc6385190b60/Runtime/Scripting/WinRTUtility.cpp Line: 88)

SEHException: External component has thrown an exception.
at WinRTBridge.SerializationWeaverReader.ReadUnityEngineObject()
at LevelMap.Unity_Deserialize()
at UnityEngine.IUnitySerializable.$Invoke0(Int64 instance, Int64* args)
at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
(Filename: TODO Line: 0)

UnloadUnusedAssets has a bug that it sometimes unloads actually used assets. You’re probably hitting this.
Calling GameObject.DontDestroyOnLoad() on particular asset should help, just the problem is to find it.

Has you fixed this bug?
It’s a madness to mark all objects like that, on switch back to previous scene i have to clean all of this objects manually.

Hi all,

this bug was not fixed yet right? This is my log:

I agree with nicloay, its not pratical to mark all the assets with GameObject.DontDestroyOnLoad(), because I’m not sure if it always crash on the same asset or not… Its very rare this to happen but I got it on the logs the last time but I’m not sure if it doesn’t crash somewere else on the other times…