- Home /
UI Text component and high memory usage problem
In my game i have a cusom logger that creates a ui Text inside a scroll view every time you log something to show log's history, but when the history gets more and more logs the memory usage increases dramatically. I tested with 1000 messages and the memory usage growth to around 800mb, is there a good way of show a high amount of messages without increase the memory usage that much? My scroll view's viewport component has a Rect mask 2d attached to it.
Answer by Jolut · Jul 02, 2020 at 12:36 AM
For anyone who ran in this problem i just found this script that shows every Debug.Log message in a OnGUI view without any RAM overhead. https://gist.github.com/mminer/975374
Answer by LexGear · Jul 01, 2020 at 11:27 PM
Can you provide the code used to log the messages? And how big are the messages? 800mb including the game engine doesn't sound unreasonable. :)
EDIT: When i say memory usage i'm talking about RA$$anonymous$$. The messages aren't bigger than 200 characters and this is the code that creates the message:
public void ShowLog(string msg)
{
GameObject new$$anonymous$$essage = Instantiate(Log$$anonymous$$essagePrefab, serverContent.transform);
new$$anonymous$$essage.GetComponent<Text>().text = msg;
}
the memory usage without messages is around 60$$anonymous$$b and it starts growing as the logs are printed
Your answer
Follow this Question
Related Questions
Unity Sprite Memory Usage Is Huge 1 Answer
UI Text compression on android 1 Answer
Render Debug.Log as UI Text 2 Answers
What's your equivalent of old GUIStyle ? 0 Answers
Canvas is flipping, 2D game 0 Answers