You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't see offset used anywhere in the following code however during tests I found that it uses up memory pretty heavily. If I did my testing right, in one case preg_match_all() uses up 80 MB with PREG_OFFSET_CAPTURE and 23 MB without.
Interesting, it looks like a leftover from the time I actually used the offset, now replaced with calculation via mb_strlen(). Would you be interested in preparing a PR for this?
I've actually tried that, but the logic in the following switch statement is a little bit over my head. What I could share is why I have investigated this, and minimal test cases which shows memory issues with that preg_match_all() statement https://1drv.ms/f/s!AgnMn-haWyFrkcN50beuEO4A0m6PQw?e=GjwcEV . Ideally I wanted to find out why these content cases uses so much memory, but other cases don't. PREG_OFFSET_CAPTURE looked like a low hanging fruit, but there could be other issues still.
@ViliusS@funkjedi the PR is merged now, and I also got another idea to make it even better using PCRE MARK verb. Unfortunately this will work in PHP 7+ only, so I'll merge it after figuring out the strategy to bump the required PHP version and modernize the codebase. My plan so far is v0.8.0 for PHP 5.3+, v1.0.0 for PHP 7.1+ and v2.0.0 for PHP 8.1+, with dedicated branches for each major version - master stays for 0.x, then v1.x, and v2.x respectively. PR is here: #116
Activity
thunderer commentedon Apr 18, 2024
Interesting, it looks like a leftover from the time I actually used the offset, now replaced with calculation via
mb_strlen(). Would you be interested in preparing a PR for this?ViliusS commentedon Apr 18, 2024
I've actually tried that, but the logic in the following
switchstatement is a little bit over my head. What I could share is why I have investigated this, and minimal test cases which shows memory issues with thatpreg_match_all()statement https://1drv.ms/f/s!AgnMn-haWyFrkcN50beuEO4A0m6PQw?e=GjwcEV . Ideally I wanted to find out why these content cases uses so much memory, but other cases don't.PREG_OFFSET_CAPTURElooked like a low hanging fruit, but there could be other issues still.thunderer commentedon Dec 20, 2024
@ViliusS @funkjedi the PR is merged now, and I also got another idea to make it even better using PCRE MARK verb. Unfortunately this will work in PHP 7+ only, so I'll merge it after figuring out the strategy to bump the required PHP version and modernize the codebase. My plan so far is
v0.8.0for PHP 5.3+,v1.0.0for PHP 7.1+ andv2.0.0for PHP 8.1+, with dedicated branches for each major version -masterstays for0.x, thenv1.x, andv2.xrespectively. PR is here: #116