Regex.split

omoba

Active Member
Licensed User
Longtime User
Hi,

In my app, I open various files and split them into words as shown in "Sub Display"

If I try to open a large text file (120kb) and split it, it takes well over 10mins to open.

I noticed that if I request to open the 120kb file straight from "Sub Activity_Create(FirstTime As Boolean)" when the app is first loading it take only 20secs to open the 120kb file.

Any idea what is going on?


Sub Display

txt = File.GetText(File.DirAssets, "text.txt") 'split text in each word

arrWord = Regex.Split(" ", txt)

For k = y To arrWord.Length - 1
Log(arrWord(k) & " " & arrWord(k).Length)
CCT.AddLinkText(lblText,arrWord(k).Trim & " ",Colors.black,"GetString")
Next
Label4.Text = Spinner1.SelectedItem
SetText
End Sub
 

omoba

Active Member
Licensed User
Longtime User
The regex.split (splitting) is the slow portion of the code. Only when the file is large. Small filesover and over no problem but once i try a large file it takes forever.
 
Last edited:
Upvote 0

omoba

Active Member
Licensed User
Longtime User
Hi,

Thanks for the help.

But I would like to open this 120kb file at will and as many times as possible while the app is running.

This is what I have noticed;

If I open the file in Sub Activity_Create when the app first loads, the file would load to the screen in about 20secs.

If I run the app (basically open other files) and then try to open the 120kb file it takes well over 5mins (once over 10mins).

Pls what could be the issue.

Could it be a memory issue or array etc

Thanks.
 
Upvote 0

omoba

Active Member
Licensed User
Longtime User
I believe this is a memory issue. I get tons of these debug line below

GC_FOR_ALLOC freed 1907K, 22% free 10005K/12807K, paused 35ms
 
Upvote 0

omoba

Active Member
Licensed User
Longtime User
It is a static file --doesnt change.

I am currently just reinitializing the whole thing when I need to open the files

Activity.Removeallview --Activity.LoadLayout --and then .......

Maybe not the best solution but it does the job.

Of course I am willing to learn if there is a way to do it better.

Thanks
 
Upvote 0

Similar Threads

Top