Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Bug TMP_TextInfo.Resize() OutOfMemoryException

Discussion in 'UGUI & TextMesh Pro' started by deab, Mar 14, 2024.

  1. deab

    deab

    Joined:
    Aug 11, 2013
    Posts:
    93
    Anything I can do to prevent this? A buffer somewhere I can increase? Language used was simplified Chinese, platform windows pc.

    Code (CSharp):
    1. STACK:
    2. System.Array.Resize[T] (T[]& array, System.Int32 newSize) (at <834b2ded5dad441e8c7a4287897d63c7>:0)
    3. TMPro.TMP_TextInfo.Resize[T] (T[]& array, System.Int32 size, System.Boolean isBlockAllocated) (at <affba3ad1dcd49ff819dae4d5ac0c85e>:0)
    4. TMPro.TextMeshProUGUI.SetArraySizes (TMPro.TMP_Text+UnicodeChar[] unicodeChars) (at <affba3ad1dcd49ff819dae4d5ac0c85e>:0)
    5. TMPro.TMP_Text.ParseInputText () (at <affba3ad1dcd49ff819dae4d5ac0c85e>:0)
    6. TMPro.TextMeshProUGUI.OnPreRenderCanvas () (at <affba3ad1dcd49ff819dae4d5ac0c85e>:0)
    7. TMPro.TextMeshProUGUI.Rebuild (UnityEngine.UI.CanvasUpdate update) (at <affba3ad1dcd49ff819dae4d5ac0c85e>:0)
    8. UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at <5affe04924dd4e7b92d6e6025197937c>:0)
    9. UnityEngine.UI.ScrollRect:LateUpdate()
    10.  
     
  2. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    853
    is this a big text that's never visibly in its entirety? like a 50 page text where only 2 pages are visible at any given time?
    if yes, there are several optimizations you could engage in. only assigning the visible text at the current position is one, but it's not easy.

    OutOfMemoryException sounds like some bad allocations inside TMPro as text is rarely a reason to fill GBs of memory, even for logograms, but my above suggestion should help a little. you still have to put in the work and code it, but hopefully this is better than nothing

    you could also try a newer TMPro version in an empty project, to check if they've fixed it
     
  3. deab

    deab

    Joined:
    Aug 11, 2013
    Posts:
    93
    I don't have any large amounts of text so I don't think that's the issue. Sadly I can't reproduce the issue as was on build in the wild.