Search Unity

Question ManagedHeap.UsedSize grows to 1.26gb

Discussion in 'Editor & General Support' started by wikmanyo, Jun 14, 2020.

  1. wikmanyo

    wikmanyo

    Joined:
    Nov 17, 2012
    Posts:
    65
    Hi,

    I have an Editor tool that is Creating Meshes... For some reason, after running the editor script a few times my ManagedHeap.UsedSize grows up massively and never goes down... (I am seeing this in the profiler)

    I tried using the Memory Profiler to try and track down what is happening using Difs, but *nothing* is showing up... Any Help appreciated...

    I'm using lots of Dictionaries and HashSets and Vector3 arrays - but everything should be cleaned up, most of the functions are things like Static WeldVerts(mesh) Static CalculateNormals(mesh) etc. Everything is allocated locally in the functions, but never seems to get freed. I even tried manually emptying my dictionary then doing a dictionary.Clear() before returning from the static functions, makes no difference....

    Unity 2018.4 LTS
     
  2. wikmanyo

    wikmanyo

    Joined:
    Nov 17, 2012
    Posts:
    65
    As an update to this, I started rewriting some of these functions to use Native Collections / Jobs and Burst and my memory is now being freed correctly... It seems using large collections on the managed heap is problematic for unity...