Help with this (C# Code)

Discussion in 'Computer Programming, Emulation, and Game Modding' started by XabiPlayerPRO, Mar 19, 2017.

  1. XabiPlayerPRO
    OP

    XabiPlayerPRO Advanced Member

    Newcomer
    50
    22
    Jan 3, 2017
    Spain
    I´m trying to put the text of very very big files (almost 3GB) on a richtextbox, and it lasts too much, and gets frozen. Anything to make it more faster?
     
  2. XabiPlayerPRO
    OP

    XabiPlayerPRO Advanced Member

    Newcomer
    50
    22
    Jan 3, 2017
    Spain
    It takes almost a minute with a 500kb file, so just with a 3gb file will be 6000 more times (lol)
     
  3. Natorite

    Natorite Newbie

    Newcomer
    4
    1
    Mar 31, 2017
    United States
    USA
    Is this WinForms or WPF?
    Also unless you do some surgery on config files, the CLR will limit your objects to being a max of 2GB in memory.

    Best solution either way will be to display the file in chunks.
    The process might look something like this:
    1. Read lines 1-10 of file.
    2. On scroll down, display lines 2-11 of the file.
    Be careful of only keeping the lines that are being displayed in your array of lines, otherwise this will lead to a huge memory leak since we're not cleaning up the lines we're not showing and essentially loading in past that 2GB anyways. You can either set the string to null to trigger the garbage collector, or overwrite it in something like an array of strings with 10 elements.