ERROR: LoadError: PCRE JIT error: no more memory

I’m encountering this error and as far as I can tell it is related to my use of a regular expression.

I’m using proprietary commercial data, so can’t easily share. However, I’m trying to read a set of files from a very large zip archive using ZipArchives.jl. I can open the archive and get a list of the 360 files it contains. I only want a small subset of these so I’m using

fmatch = "^Code-Point\Data\CSV\HD.[a-z]{3}"
allmatch=(n[occursin.(Regex(fmatch), n)])

This crashes with the above error.

Another file in the big zip file is a second, nested zip file. I can read this using ZipArchives.jl and, using a simpler regex, this method works fine, doesn’t crash, and produces the reduced list of matching files:

fmatch = "^HD.[a-z]{3}"
allmatch=(n[occursin.(Regex(fmatch), n)])

I’m using julia 1.10.3 under windows. I’m in a corporate environment where my pc is controlled by IT.

Does anyone have any suggestions?

As a follow-up, I changed the match term to exclude the explicit regex:

fmatch = "Code-Point\\Data\\CSV\\HD.csv"
allmatch=(n[occursin.(fmatch, n)])

and this still produced the same error. The full message was:

ERROR: LoadError: PCRE JIT error: no more memory
  [1] error(s::String)
    @ Base .\error.jl:35
  [2] jit_compile
    @ .\pcre.jl:175 [inlined]
  [3] compile(regex::Regex)
    @ Base .\regex.jl:81
  [4] Regex(pattern::String, compile_options::UInt32, match_options::UInt32)
    @ Base .\regex.jl:40
  [5] Regex
    @ .\regex.jl:68 [inlined]
  [6] readCSVFiles(postcode::String)
    @ Main c:\Users\TGebbels\...\NLPU Shared\OS Data\NewTryPostcodes-NLHFmethod.jl:135
  [7] macro expansion
    @ c:\Users\TGebbels\...\NLPU Shared\OS Data\NewTryPostcodes-NLHFmethod.jl:177 [inlined]
  [8] macro expansion
    @ .\timing.jl:279 [inlined]
  [9] main()
    @ Main c:\Users\TGebbels\...\NLPU Shared\OS Data\NewTryPostcodes-NLHFmethod.jl:168
 [10] top-level scope

It looks like you may be repeatedly compiling the expression for every CSV file.

Could you put a const Regexp somewhere and then reuse it?

Actually I see another issue. The \ need to be escaped.

const fmatch = r"^Code-Point\\Data\\CSV\\HD.[a-z]{3}"

I can’t move the regexp because the HD part is actually a computed value that is only known within the loop. Each iteration of the loop needs a different csv file.

I wasn’t aware that escaping in regular expressions was different from the normal escaping in julia strings - hence the use of \\. Now I know! :slightly_smiling_face:

The problem actually turned out (as usual) to be down to my error. The character in question should have been / not \! Once this change was made, the problem went away.

The error PCRE JIT error: no more memory was singularly unhelpful to this learner!

Some of the escaped characters have special meanings in PCRE.