Massive CPU spike when changing Loc term

More
7 years 1 month ago #2078 by dt1000
Hi there.
Whenever I use the command Loc.SetTerm to change the localisation term of an nGUI label I get a massive CPU spike.
According to the profiler, this is caused by...

Loading.UpdatePreloading
Application.Integrate Assets in Background
GarbageCollectAssetsProfile
GC.MarkDependencies

Am I doing something wrong?

Please help - my project is for mobile and this is causing big problems.

Cheers,
Dan

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

More
7 years 1 month ago #2079 by dt1000
Hmmm. Researched a bit on the forum and found some clues.

In ResourceManager.cs on line 143...

Invoke("CleanResourceCache", 0.1f);

...seems to be causing the glitch, so I commented it out and left it for Unity to handle automatically.

Is this a safe thing to do?

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

More
7 years 1 month ago - 7 years 1 month ago #2080 by Frank
That's weird, After you commented that line the spike stopped, or did it moved to another function?

Normally, the CleanResourcesCache will not generate an spike given that I2 Localization doesn't load much from the resources. That function is even delayed 0.1s to avoiding having the lag in the same frame the localization happens.

However, it could indeed generate a spike if the project has already loaded lots of things from the Resources and then hasn't unload them after no one is referencing them. When the call to CleanResourcesCache happens, then unity will also free the memory of all the other unused assets.

Is this a safe thing to do?


yes.

However, to be safer (and free memory) its better to call CleanResourcesCache when transitioning to a new level.
I'm going to release that change in the next beta.

You can comment the invoke of the CleanResourcesCache as you did, and then add the call to the OnLevelWasLoaded function at line 56:
		#if UNITY_5_4_OR_NEWER
		public static void MyOnLevelWasLoaded(Scene scene, LoadSceneMode mode)
		#else
		public void OnLevelWasLoaded()
		#endif
		{
			pInstance.CleanResourceCache();      //<---- add this line
			LocalizationManager.UpdateSources();
		}

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 1 month ago by Frank.

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

Time to create page: 0.152 seconds
Template by JoomlaShine