Exemplo n.º 1
0
    /// <summary>
    /// 用于监控内存
    /// </summary>
    /// <param name="tag"></param>
    static void MonitorMemorySize()
    {
        if (ApplicationManager.AppMode != AppMode.Release)
        {
            totalReservedMemory  = ByteToM(Profiler.GetTotalReservedMemoryLong());
            totalAllocatedMemory = ByteToM(Profiler.GetTotalAllocatedMemoryLong());
        }

        if (tempTime <= 0)
        {
            tempTime = UpdateMemoryTime;
            if (MemoryInfo.GetMemoryInfo())
            {
                freeMemory = MemoryInfo.minf.memfree / 1024f / 1024f;
                allMemory  = MemoryInfo.minf.memtotal / 1024f / 1024f;
                usedMemory = MemoryInfo.minf.memused / 1024f / 1024f;
            }
        }
        else
        {
            tempTime -= Time.deltaTime;
        }

        AssetsUnloadHandler.LateUpdate();

        if (NeedReleaseMemory() && OpenAutoMemoryClean)
        {
            AssetsUnloadHandler.UnloadOne();
        }
    }