Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

why not free memory il2cpp

Discussion in 'Scripting' started by dowon951, Dec 6, 2021.

  1. dowon951

    dowon951

    Joined:
    Jun 24, 2019
    Posts:
    12
    I saw something strange while managing the memory of the project I'm working on.

    whenever a generic class is used, memory is allocated from li2cpp memadata and is not released until the end.

    This is a problem because we manage a fairly large amount of data using generic classes.

    Is there any way to free this?

    If you can't do this, I'd like to know why il2cpp is configured to not unload these memories.
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,787
    There is no way to free this memory. The runtime must allocate some memory to support reflection code, and this memory is not deallocated because the runtime does not know when it is no longer used. We don't currently have a way for the client code to tell the runtime that it is no longer used.

    We do have changes coming to IL2CPP on mobile platforms that use a data structure to store this information which is optimized to use less memory, so that may help the situation in your case.
     
    Yoreki and VolodymyrBS like this.
  3. dowon951

    dowon951

    Joined:
    Jun 24, 2019
    Posts:
    12
    Where can I check the changelog
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,787
  5. dowon951

    dowon951

    Joined:
    Jun 24, 2019
    Posts:
    12