Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running regex on string defined in a loop eats tons of memory #3714

Open
p6rt opened this issue Mar 3, 2015 · 1 comment
Open

Running regex on string defined in a loop eats tons of memory #3714

p6rt opened this issue Mar 3, 2015 · 1 comment
Labels

Comments

@p6rt
Copy link

p6rt commented Mar 3, 2015

Migrated from rt.perl.org#123974 (status was 'new')

Searchable as RT123974$

@p6rt
Copy link
Author

p6rt commented Mar 3, 2015

From avuserow@gmail.com

This is perl6 version 2015.02-157-g28fddba built on MoarVM version
2015.02-17-g86d0c68, running on Fedora 21 x64.

(All memory usages gathered via maxresident from /usr/bin/time)

Things that eat a lot of memory​:

/usr/bin/time perl6 -e'for 1 .. 1000 {my $a = "a" x 1_000_000; $a ~~ /./;}'
4010652maxresident

/usr/bin/time perl6 -e'for 1 .. 1000 {my $a = "a" x 1_000_000; $a ~~ /z/;}'
3775768maxresident

/usr/bin/time perl6 -e'my $a; my $i = 0; while $i < 1000 {$a = "a" x
1_000_000; $a ~~ /./; $i++};'
4011284maxresident

For these cases, if I replace 1000 with 100, then I use right around
500MB in these cases. JVM does not appear to be affected or affected as
badly, as I can ramp up 1000 to 10000 and still be around 1GB.

Things that don't consume tons of memory​:
/usr/bin/time perl6 -e'my $a = "a" x 1_000_000; for 1 .. 1000 {$a ~~ /./;}'
106320maxresident

/usr/bin/time perl6 -e'for 1 .. 1000 {my $a = "a" x 1_000_000; $a.chars}'
92552maxresident

(Note that my real use case has distinct values since they are being
read from a file with similar line-length characteristics.)

@p6rt p6rt added the perf label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant