- Home /
AssetDatabase.Refresh Causes Fatal Error: Out of Memory
For some reason when my editor script reaches AssetDatabase.Refresh, the editor's memory usage spontaneously explodes and the Unity editor crashes giving me "Fatal Error: Out of Memory". The first time I run my editor script, it always works, and the second time I run the script, it always fails. The basic idea my script goes through is this:
Copy a png file into the project using FileUtil
Call AssetDatabase.GenerateUniqueAssetPath for the path I just copied to
Call AssetDatabase.Refresh
Call AssetDatabase.ImportAsset for the path I just copied to.
Call AssetDatabase.LoadAssetAtPath for the path I just copied to.
The png file I load is about 6MB large, but I noticed that the page file usage (RAM) jumps about 200 MB when the editor loads it in using ImportAsset. When the application fails on the refresh, the RAM jumps from 1.3 GB to 1.6 GB. Would somebody please tell me:
Why would AssetDatabase.Refresh cause the fatal out of memory exception?
Why does so much more RAM get consumed by the image than it really takes?
Would anybody please explain to me the correct order to call all of the asset database functions after you copy in a file? Unfortunately Unity has barely documented the correct way to use the AssetDatabase functions, as usual, forcing me to spend weeks in trial and error mode. Yes, I have already read this:
http://unity3d.com/support/documentation/Manual/AssetDatabase.html
and it does not answer my questions. Does not even come close to explaining what I need to know.
Here's a funny thing, I commented out that line to refresh the database. The code obviously did not work obviously, but it still does not crash the first time but consistently crashes the second time I run it.
Your answer
Follow this Question
Related Questions
Refresh single asset 1 Answer
EditorSceneManager.OpenScene fails after AssetDatabase.Refresh 1 Answer
assetdatabase3 is corrupted... 0 Answers
AssetDatabase.Refresh () 2 Answers
File Couldn't be Read 0 Answers