nodecanvas reflection memory issue

NodeCanvas Forums Support nodecanvas reflection memory issue

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #15054
    toro_rosso
    Participant

    hello,

    so we have another issue with nodecanvas. the code in ReflectionTools.cs is highly inefficient when used with il2cpp (the default for ios)

    see, by iterating all the assemblies and types at startup, il2cpp creates a cache of all reflection metadata (which is never unloaded), which ends up taking about 150megs of ram (you will only see this memory if you use xcode instruments)

    I’ve looked at the latest source code, and it still uses that pattern.

    in our case, it iterates over 250 assemblies and I dont know how many types.

    this is what Unity told us:

    The recommendation is to avoid using reflection since il2cpp VM needs to allocate memory for the metadata of the types used on the application; this is required when reflection is used, for example, to iterate the assemblies.

    With AOTClassGenerator, could it be possible to generate the list of used types, and check that instead of iterating through all the types?

     

     

    #15058
    Gavalakis
    Keymaster

    Hello there,

    Hmm. I could possibly somehow limit the list of types to iterate and cache based on the Preferred Types that you have in the Preferred Types Editor only. However, il2cpp also has code stripping, thus types that are not “referenced” in link.xml should be stripped and not be used by ReflectionTools methods, but of course there a lot of other assemblies/types that are included non-the-less. Please also note that the default generated link.xml is including the whole c# assembly for convenience (which may be an overkill but can be modified).

    With that said, your suggestion is nice. I will take a look at the ability to only make use of types explicitly added in the Preferred Types Editor. Please let me know if that sounds like a good solution for you.

    Thank you!

    Join us on Discord: https://discord.gg/97q2Rjh

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.