B4J Question Tableview loading 120 000 rows form a 7MB file, ram usage goes to 4GB

Coldrestart

Member
Licensed User
Longtime User
Hello everyone,

I have a datafile of 7MB of data, as a csv file.
I load it with the following code into a tableview.
The code works, but even in release mode, my ram memory goes to 4GB, as the file with the data is just 7MB...

What am I doing wrong?
I know for each "cell" a label object is created, is that the reason that it takes so many memory?


Loading data to tableview:
TV_RAW_DATA.Items.Clear
       

        Dim row() As Object
       
        For i = 0 To List1.Size-1
                           
            Cols =  Regex.Split(DelimiterInternal(chb_Delimiter.SelectedIndex),List1.Get(i))  
           
            'If we have column names, then add the as column name first.
            If (chkb_ColumnNamesOnFirstLine.Checked = True) And (i = 0) Then
                TV_RAW_DATA.SetColumns(Cols)
                                           
                Else  

                    'Otherwise, just add the data  
                row =  CreateRow(Cols)
                TV_RAW_DATA.Items.Add(row)
               
            End If          
        Next

Create row function:
Sub CreateRow(Row() As String) As Object()
    Dim labels(Row.Length) As Object
    For i = 0 To Row.Length - 1
        Dim lbl As Label
        lbl.Initialize("")
        lbl.Text = Row(i)
        labels(i) = lbl
    Next
    Return labels
End Sub
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
What am I doing wrong?
Showing all that information at the same time is really an issue. for each cell you are creating a label, for each row you are creating an array of labels so 7mb of data is just a lot of columns and a lot of rows.

TableView was not made to be shown that many information. You want to use B4xTable that will keep in memory most of that data and only show a very small percentage of it to the user.
 
Upvote 0

xulihang

Active Member
Licensed User
Longtime User
Since the screen cannot display all the information, you can use lazy load to save memory.

These are for list view. You may need to adapt this for Tableview:

 
Upvote 0

Coldrestart

Member
Licensed User
Longtime User
I switched to B4XTable, and have some issues.
First, I want to check the members on the website under "learn" and "guides", but there I don't see any information of the functions.

How can I make the header labels or fields bigger, to show all header data? (like the number of page that is shown)


1641407865186.png


Thanks in advance.

I started a new thread for this question:
 
Last edited:
Upvote 0
Top