Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

en_us Localeでは、ScriptableObjectのリークが発生します #136

Closed
bdunderscore opened this issue May 2, 2024 · 0 comments
Closed

Comments

@bdunderscore
Copy link

return ScriptableObject.CreateInstance<LocalizationTable>();

この件はLocalizationTableをリークしてしまい、C#オブジェクトと違ってエディター再起動までヒープに残ってしまいます。そのため、Resources.FindObjectsByTypeAllなどのヘルパーが非常に重くなり、いろんな操作が重くなります。

リークを確認した時点では16GBほどのヒープサイズになってました(メモリーダンプは解析できなかったので確定ではないが、再起動した後はここだけが急速に増えてました)

ハックではありますが、このような修正を入れたらオブジェクトの増加が止まりました

        private static LocalizationTable en_us;
        
        public static LocalizationTable GetTable(Locale locale)
        {
            if (locale == Locale.ja_JP)
            {
                return AssetDatabase.LoadAssetAtPath<LocalizationTable>($"{DetailConstants.LocalizationDirectory}/ja_JP.asset");
            }
            else
            {
                // en_US has the table in source code, not asset.
                en_us = en_us != null ? en_us : ScriptableObject.CreateInstance<LocalizationTable>();

                return en_us;
            }
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants