Search Unity

Question Best way to handle large collections of strings to Json

Discussion in 'Editor & General Support' started by JacobDecisionLab, Jan 17, 2023.

  1. JacobDecisionLab

    JacobDecisionLab

    Joined:
    Nov 16, 2022
    Posts:
    9
    For my current project, one of the main goals is to have a large amount of generated data which is outputted at the end of the model. A lot of this will be as long strings of generated text

    I am expecting to end up with 1000s of data entries which will primarily be made up of strings. Currently I am storing them as collections of structs and outputting them to json at model finish, but this has just been for testing purposes and I am aware that this will likely lead to performance issues down the line due to the garbage collector going through a large quantity of strings

    What is a better way of doing this?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    I wouldn't be so quick to assume. My KurtMaster2D game collection uses a 2048-byte string buffer to communicate back and forth between native mode and Unity mode, filling that buffer EVERY FRAME with fresh data, data which is then torn apart into dozens or even hundreds of smaller sub-strings (every frame!) and it never stumbles.