Hard crashes in Mid, MidB and Join - again

Some time ago I asked about hard crashes in the Mid function. See https://forum.xojo.com/7304-crash-at-stringdbcsmid2 . I even did a Feedback issue(feedback://showreport?report_id=31385).

Since then I’ve got also crashes in MidB and Join. The Join joins some strings. The MidB is from ages old SplitByRegex from Joe Strout:

Protected Function SplitByRegEx(source As String, delimPattern As String, checkSource as Boolean = False) As String()

Dim out(-1) As String
Dim startPos As Integer

Dim re As New RegEx
re.SearchPattern = delimPattern
Dim rm As RegExMatch = re.Search(source)
while rm <> nil
out.Append MidB(source, startPos + 1, rm.SubExpressionStartB(0) - startPos)
startPos = re.SearchStartPosition
rm = re.Search

if startPos < source.LenB then out.Append MidB(source, startPos + 1)
if UBound(out) > 0 then return out

End Function

All this is old code, which parses one single mail in a thread. Mails over 1 mb are rather rare.

I even tried to use StringHandleMBS. But this is way slower and also crashes.

Are these really memory problems? If yes, why didn’t they show up under Carbon? How do I work around these?

I forgot: Xojo 2013r4, Mac OS 10.9.

I thought about creating a Join functions for my plugin.
But the problem is that creating a String in Xojo does not handle the low memory case well.

I don’t understand: I’m parsing one single mail here. Maximum 10 mb. I just checked the memory of my app. It’s between 130 and 150 mb.

31385 is a crash log from a process running out of memory

@Norman: thanks for the information. I really hadn’t believed Christian. It also would have helped to have this information in the Feedback issue.

Shouldn’t virtual memory be handled automatically??? Would it help to adjust stack/heap memory (I forgot which can be adjusted)? I remember having problems with regexes and having to fiddle around with this.

Sigh… at least I now can do some testing.

RegExMBS won’t hard crash on you so consider that as an alternative. I have a similar SplitByRegEx function in my M_String module that uses MBS instead, if memory serves.