eblattner
Programmer
- Aug 10, 2000
- 33
Hey all. I have a problem displaying a binary file in a DataGridView control. This program is basically a binary editor/mapper for automotive PCM files. Loading the file in to the array is very fast (less than 5 seconds), displaying in the grid is slow (no biggie), but the biggest problem I have is memory usage.
The binary files I'm reading are either 512k or 1024k. I import a file into an array, then display it in the DataGridView. This is where the problem comes, for a 512k file, this program uses about 95 megs (over the memory it used just to run). If I skip loading the datagrid, it's fine.
Here is the code...
If I rem out the DataGridView lines and leave everything else in this routine alone, there is no memory problem.
I am lost as to what I am doing wrong, any help is appreciated. Thanks in advance
The binary files I'm reading are either 512k or 1024k. I import a file into an array, then display it in the DataGridView. This is where the problem comes, for a 512k file, this program uses about 95 megs (over the memory it used just to run). If I skip loading the datagrid, it's fine.
Here is the code...
Code:
ReDim BinaryFile(FileLength - 1)
For i = 0 To FileLength - 1
b += 1
tmpByte = r.ReadByte
BinaryFile(i) = tmpByte
tmp_Str = Hex$(tmpByte)
If tmp_Str.Length = 1 Then
tmp_Str = "0" & tmp_Str
End If
DataGridView1.Rows(a).Cells(b - 1).Value = tmp_Str
If b = 16 Then
a += 1
MyPosition = Hex$(a)
If MyPosition.Length < 4 Then
Select Case MyPosition.Length
Case 1
MyPosition = "000" & MyPosition
Case 2
MyPosition = "00" & MyPosition
Case 3
MyPosition = "0" & MyPosition
End Select
End If
b = 0
DataGridView1.Rows.Add()
DataGridView1.Rows(a).HeaderCell.Value = MyPosition
End If
Next i
If I rem out the DataGridView lines and leave everything else in this routine alone, there is no memory problem.
I am lost as to what I am doing wrong, any help is appreciated. Thanks in advance