Memory Questions

More
7 years 5 months ago #1847 by JohnLawrie
Memory Questions was created by JohnLawrie
Hello. I have a questions about memory usage using I2 Localization.

I recently went through my game and converted all object that have a Text Mesh Pro text fields to also have a Localize component associated with it. Every one of these localize components has a secondary term that is used to set the font per language.

If I launch the game into English and never switch to another language, I can see that all of the font atlases are loaded, a few of them multiple times. For example, the Korean Hangul and Most common Chinese characters are loaded.

I was expecting that I2 Localization would load into memory the Text Mesh Pro font for the language used and would free up the other Text Mesh Pro fonts until they are needed again. However, this appears to not be happening.

None of these fonts are reference in the Text Mesh Pro global setting (TMP Settings)

These are my font tems that are currently in our project
Fonts/UnbundledBodyFont	TextMeshPFont	Unbundled	Brix-Sans-Medium-SDF	Brix-Sans-Medium-SDF	Brix-Sans-Medium-SDF	Brix-Sans-Medium-SDF	Brix-Sans-Medium-SDF		NotoSansCJKtc-Regular (Unbundled) SDF		NotoSansCJKkr-Regular (Korean Hangul) SDF	Brix-Sans-Medium-SDF	Russian SDF	
Fonts/UnbundledHeaderFont	TextMeshPFont	Unbundled	Elephantmen Bold	Elephantmen Bold	Elephantmen Bold	Elephantmen Bold	Elephantmen Bold		NotoSansCJKtc-Regular (Unbundled) SDF		NotoSansCJKkr-Regular (Korean Hangul) SDF	Elephantmen Bold	Russian SDF	
Fonts/BundledBodyFont	TextMeshPFont		Brix-Sans-Medium-SDF	Brix-Sans-Medium-SDF	Brix-Sans-Medium-SDF	Brix-Sans-Medium-SDF	Brix-Sans-Medium-SDF		NotoSansCJKtc-Regular (Bundled) SDF		NotoSansCJKkr-Regular (Korean Hangul) SDF	Brix-Sans-Medium-SDF	Russian SDF	
Fonts/BundledHeaderFont	TextMeshPFont		Elephantmen Bold	Elephantmen Bold	Elephantmen Bold	Elephantmen Bold	Elephantmen Bold		NotoSansCJKtc-Regular (Bundled) SDF		NotoSansCJKkr-Regular (Korean Hangul) SDF	Elephantmen Bold	Russian SDF	
Fonts/BundledChatFont	TextMeshPFont		Brix-Sans-Medium-SDF	Brix-Sans-Medium-SDF	Brix-Sans-Medium-SDF	Brix-Sans-Medium-SDF	Brix-Sans-Medium-SDF		NotoSansCJKtc-Regular (Common 8501 Sheet 1) SDF		NotoSansCJKkr-Regular (Korean Hangul) SDF	Elephantmen Bold	Russian SDF	

Every single Localize component will have one of these fonts assigned as the secondary term.

Here is a screenshot from the Unity memory profile where you can see multiple reference to these objects.

One other point of info which may or may not be relevant is that some entries are in I2Languges. These are terms that we need before we could download an asset bundle. We also have some terms in a file we call CCGI2Languages-Bundles. This file comes from an asset bundle.

Any insight would be greatly appreciated.
Thanks


Attachments:

Please Log in or Create an account to join the conversation.

More
7 years 5 months ago #1848 by Frank
Replied by Frank on topic Memory Questions
Hi,
If the fonts are not in the Resources folder, then the plugin HAS to make a reference to them. The problem with references is that Unity always loads the first two hierarchy levels of all references (in case of font, the entire font, material and texture)

The solution to avoid having those fonts loaded when not needed, is to move them to a Resources folder. I2 Localization will detect they are in Resources and instead of keeping a reference to them, it will just store their Path. Then it will just call Resources.Load when needed.

Please, notice that if you already have the font referenced, if you move them to the resources folder, SmartEdge will still keep a reference to them as it was already set. You will have to manually go to the "Assets" tab in the I2Languages.prefab and remove them. That will make the plugin delete the reference and use the path instead.

Also, if you added fonts to Localize components (instead of just to the i2Languages.prefab) you will need to remove the reference from the "Referenced Assets" section at the end of the Localize component.

As of the last version 2.6.8, the plugin also supports storing the Fonts in AssetBundles using the AssetBundleManager, so thats another option if you need to download new fonts!

Hope that helps,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

More
7 years 5 months ago #1849 by JohnLawrie
Replied by JohnLawrie on topic Memory Questions
Ok, I'll give that it a shot moving fonts to the resources folder and checking out the memory usage.

It looks like we are on 2.6.7. It seems like it might be worth upgrading to the the AssetBundleManager support. It is a simple upgrade?

John

Please Log in or Create an account to join the conversation.

More
7 years 5 months ago #1851 by Frank
Replied by Frank on topic Memory Questions
I always try to make it as smooth as possible.
But if you get any problem at all, just let me know and I will assist you.

Here are some instructions on how to upgrade: www.inter-illusion.com/forum/i2-localiza...-asked-questions#837

Normally you don't need to Export/Import the spreadsheet, but its advised that you at least export it, in case there is any issue you have a backup!

Hope that helps,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

More
7 years 5 months ago #1852 by JohnLawrie
Replied by JohnLawrie on topic Memory Questions
Sorry if this post shows up twice, but It looks like somehow my last response didn't get posted somehow.

So I did move my fonts to a resources folder. They now longer show up in my asset bundled that contained my CCGI2Languages-Bundled prefab.

I also did go into I2Languages.prefab and CCGI2Languages.prefab and removed the referenced items from the Assets tab of both of these files.

However, my memory profile in Unity still looks about the same with all of the font atlases showing up and some of them more than once.

I don't quite understand what you mean when you say

Also, if you added fonts to Localize components (instead of just to the i2Languages.prefab) you will need to remove the reference from the "Referenced Assets" section at the end of the Localize component.


All of the Localization components have a terms assigned in the secondary component. This term is one of the 5 I mentioned earlier:
Fonts/UnbundledBodyFont
Fonts/UnbundledHeaderFont
Fonts/BundledBodyFont
Fonts/BundledHeaderFont
Fonts/BundledChatFont

I have found one entry with a secondary term that contains the name of a font. This appears to be created automatically by I2Localization somehow. I don't know is this causes an issue, but I will change any of these that I find.

I assume that the "References" section at the bottom of the Localize component is the "Referenced Assets" you refer to earlier. Is there a way to determine if any of the Localize components have reference fonts that need to be cleared out?

Any advice appreciated.

Thank You
John Lawrie
Attachments:

Please Log in or Create an account to join the conversation.

More
7 years 5 months ago - 7 years 5 months ago #1860 by Frank
Replied by Frank on topic Memory Questions

However, my memory profile in Unity still looks about the same with all of the font atlases showing up and some of them more than once.


When fonts are in the Resources Folder and not referenced in the "Assets" section of the I2Languages.prefab or "References" section of the Localize component, they only exist as the Path to that font, just a string. So, the fonts are not loaded by I2Loc.

Please, notice, that if you are testing in the Unity Editor, the fonts can be shown as loaded (and referenced) if you had them referenced before or selected the font (and sometimes even if you open the folder where they are).
You will need to restart the editor for them to not show unloaded again, and always test this in a deployed build. Just build for a device or desktop and attach the profiler.

I assume that the "References" section at the bottom of the Localize component is the "Referenced Assets" you refer to earlier.


Yes, is the "References" section!



Also, I see you have more than one LanguageSource (I2Languages.prefab and CCGI2Languages.prefab), please check that there are no files referenced in the "Assets" tab of those prefabs.

Hope that helps,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
Last edit: 7 years 5 months ago by Frank.

Please Log in or Create an account to join the conversation.

Time to create page: 0.616 seconds
Template by JoomlaShine