-
Notifications
You must be signed in to change notification settings - Fork 14
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
Excessive memory usage - packing long code crashes the browser #46
Comments
Chrome grows to 750Mb then crashes. I recorded the same behavior on the prototype for v5.0 with a packer rewritten from scratch. |
Thanks for the analysis. (and glad to hear about an upcoming 5.0) If it can help, I got the same issue while I was packing the js1k entry "jsotopes": this version worked fine:
But this one, crashed the packer:
The only difference between both versions is that in the second one, I reuse the long string twice instead of assigning it to the variable e |
Can you please post base64-encoded strings for those two versions of jsotopes ? Control characters are not supported by GitHub's bugtracker. |
Hi guys! I just tried running Maxime's string on my web server using Node on the CLI and I (eventually) was able to successfully output a packed file. This doesn't seem to be a problem with RegPack, but rather just the limitations of the browser :) |
jsotopes short base64'd in utf-8:
jsotope long base64'd in utf-8:
as @tomhodgins says (thanks and hi tommy), I think it's just a super-resource-consuming loop done by the packer that the browser doesn't like... EDIT: for the record, the packed code that tommy managed to get is only 941b. |
The crusher stage is memory intensive. I'll perform a few more tests but I reckon the only way to fix this is to completely rewrite the algorithm. This is due for v5.0, see #7. I'll keep an eye on performance while working on the new one. Update : I did not get the crash when packing jsotopes (long version). Both FF and Chrome coughed a little and required 400 Mb yet they went through. Maybe a smaller configuration will not support it. But I have a slight idea of what happened - the longest repeating string is 905b long. The crusher built a dictionary with one instance of that string, but then it had 2 strings of 904b, 3 of 903b and so on. The memory usage is o(n²). The goal for #7 is to keep only the longest relevant strings. |
I've encountered this problem a few times this month.
I have a long minified code (~3kb) containing a lot of repetitions, and when I try to regpack it in any browser, I get no output, and the browser crashes. (Fx, Chrome, Edge, all the same).
Here's the code I want to pack:
I tried to pack it with all the options unchecked, but had the same problem.
Any idea?
Maybe the packer creates too many tokens and overflows out of ASCII and breaks everything?
(PS: I use the online packer regpack 4.0. Couldn't try command-line because... dunno how to install it)
(PS2: Strangely, this code, just a little shorter, packs well in ~957b:)
The text was updated successfully, but these errors were encountered: