# ERROR: LoadError: PCRE JIT error: no more memory

**URL:** <https://discourse.julialang.org/t/error-loaderror-pcre-jit-error-no-more-memory/113859>\
**Category:** General Usage\
**Tags:** regex\
**Created:** [May 5, 2024, 11:33am UTC](https://discourse.julialang.org/t/error-loaderror-pcre-jit-error-no-more-memory/113859 "2024-05-05T11:33:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TimG](https://avatars.discourse-cdn.com/v4/letter/t/82dd89/32.png) [@TimG](https://discourse.julialang.org/u/TimG)\
**Post date:** [May 5, 2024, 11:33am UTC](https://discourse.julialang.org/t/error-loaderror-pcre-jit-error-no-more-memory/113859/1 "2024-05-05T11:33:47Z")

</div>

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

```julia
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:

```julia
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?

---

<div class="post-metadata">

**Author:** ![TimG](https://avatars.discourse-cdn.com/v4/letter/t/82dd89/32.png) [@TimG](https://discourse.julialang.org/u/TimG)\
**Post date:** [May 5, 2024, 11:37am UTC](https://discourse.julialang.org/t/error-loaderror-pcre-jit-error-no-more-memory/113859/2 "2024-05-05T11:37:23Z")

</div>

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

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

```

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

```julia
ERROR: LoadError: PCRE JIT error: no more memory
Stacktrace:
  [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
```

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [May 6, 2024, 12:59am UTC](https://discourse.julialang.org/t/error-loaderror-pcre-jit-error-no-more-memory/113859/3 "2024-05-06T00:59:30Z")

</div>

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.

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

```

---

<div class="post-metadata">

**Author:** ![TimG](https://avatars.discourse-cdn.com/v4/letter/t/82dd89/32.png) [@TimG](https://discourse.julialang.org/u/TimG)\
**Post date:** [May 8, 2024, 1:34pm UTC](https://discourse.julialang.org/t/error-loaderror-pcre-jit-error-no-more-memory/113859/4 "2024-05-08T13:34:39Z")

</div>

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! 🙂

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!

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [May 8, 2024, 6:58pm UTC](https://discourse.julialang.org/t/error-loaderror-pcre-jit-error-no-more-memory/113859/5 "2024-05-08T18:58:08Z")

</div>

Some of the escaped characters have special meanings in PCRE.

[https://www.pcre.org/current/doc/html/pcre2pattern.html#SEC1](https://www.pcre.org/current/doc/html/pcre2pattern.html#SEC1)
