- Home /
Question by
termway · Feb 19, 2015 at 03:29 PM ·
editormemorymemory-leakallocation
Editor memory leak
I'm currently trying to import custom file format and using AssetPostprocessor to archieve my goal. It's working for small file but isn't working for big file due to a memory leak and eventually end in an out of memory exception. I looked around and find that a simple list allocation seems to leaking memory. My scene is empty and I press reimport on random file to run this code using latest Unity version (4.6.2f1). Am I missing something ? Can you replicate this leak ? Why doesn't gc clear the memory ?
using UnityEditor;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class MemoryLeak : AssetPostprocessor
{
static void OnPostprocessAllAssets(string[] importedAssets,
string[] deletedAssets,
string[] movedAssets,
string[] movedFromAssetPaths)
{
Debug.Log("Mono heap size : " + (Profiler.GetMonoHeapSize() / 1000000f) +
"Mo - Mono used size : " + (Profiler.GetMonoUsedSize() / 1000000f) +
"Mo - Allocated memory : " + (Profiler.GetTotalAllocatedMemory() / 1000000f) +
"Mo - Reserved memory : " + (Profiler.GetTotalReservedMemory() / 1000000f) +
"Mo - Unused reserved memory : " + (Profiler.GetTotalUnusedReservedMemory() / 1000000f) + "Mo");
List<Vector3> points = new List<Vector3>(20000000);
//0 effect on memory
//points.Clear();
//points = null;
//System.GC.Collect(System.GC.MaxGeneration, System.GCCollectionMode.Forced);
//Resources.UnloadUnusedAssets();
//EditorUtility.UnloadUnusedAssets();
}
}
Any help would be appreciated.
log.png
(122.0 kB)
Comment