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

PWA Webpack Potential Memory Leak/Large Memory Usage #649

Open
arimgibson opened this issue Dec 16, 2022 · 6 comments
Open

PWA Webpack Potential Memory Leak/Large Memory Usage #649

arimgibson opened this issue Dec 16, 2022 · 6 comments
Assignees

Comments

@arimgibson
Copy link
Contributor

arimgibson commented Dec 16, 2022

Trying to use Padloc on a lower tier VM provided through Linode and running into some memory heap issues. I'm wondering if it's possible that there's a memory leak occurring during the Webpack bundling, or if potentially switching to something like generally faster than Webpack like Vite might help with memory usage?

I wasn't able to find any benchmarks comparing memory usage between Vite and Webpack, but it seems strange that the PWA would require significant memory to be able to build. In the meantime, I'm upgrading my VM to try and get an idea of how much memory is needed, and might resort to bundling locally and then uploading to a lower tier VM.

Update: a VM with 2GB was able to build successfully after 114804ms. That's better than I was expecting to be honest, but I'd still be curious if the required memory could be brought down a bit.

> @padloc/pwa@4.2.0 build
> webpack


<--- Last few GCs --->

[9360:0x666b830]    69185 ms: Scavenge 477.4 (496.7) -> 476.3 (496.7) MB, 15.7 / 0.0 ms  (average mu = 0.695, current mu = 0.806) allocation failure 
[9360:0x666b830]    69204 ms: Scavenge 477.8 (496.7) -> 477.0 (496.7) MB, 4.5 / 0.0 ms  (average mu = 0.695, current mu = 0.806) allocation failure 
[9360:0x666b830]    69214 ms: Scavenge 478.3 (496.7) -> 476.6 (500.7) MB, 3.3 / 0.0 ms  (average mu = 0.695, current mu = 0.806) allocation failure 


<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb06730 node::Abort() [webpack]
 2: 0xa1b6d0  [webpack]
 3: 0xce1e60 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [webpack]
 4: 0xce2207 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [webpack]
 5: 0xe99875  [webpack]
 6: 0xea953d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [webpack]
 7: 0xeac23e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [webpack]
 8: 0xe6d77a v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [webpack]
 9: 0x11e64e6 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [webpack]
10: 0x15da159  [webpack]
Aborted

With some direction, happy to investigate more; I don't have a good idea what next debugging steps might be. I might be able to submit a PR for migrating the PWA to Vite, but can't guarantee I'll have the time. Thanks!

@BrunoBernardino
Copy link
Contributor

Hi @arimgibson indeed webpack is the main resource (ab)user here, but we haven't tested anything else (like esbuild or vite). 2GB RAM is also what we found out was necessary as a minimum from DigitalOcean to build the PWA.

@BrunoBernardino BrunoBernardino self-assigned this Dec 16, 2022
@arimgibson
Copy link
Contributor Author

Hmmm okay, good to have that context. If there are significant performance improvements, would a PR to Vite be considered? I'd be happy to get started on it, though might need some help deciphering the webpack.config.js 😅

@BrunoBernardino
Copy link
Contributor

I think we'd definitely be open to that, even if it's just on one of the packages. @MaKleSoft please correct me if I'm wrong.

@MaKleSoft
Copy link
Collaborator

The current build pipeline is definitely quite resource-intensive and wasteful, and I've been itching to get away from webpack and toward something simpler / more efficient like esbuild/vite for a while now. Unfortunately I have a feeling that replacing webpack completely could be quite an undertaking with a lot of risks and potential unintended side effects, and will likely require relatively intimate familiarity with the code base. So while I appreciate the offer, I think this might be a little bit too much for a first-time contributor 😅

@arimgibson
Copy link
Contributor Author

The current build pipeline is definitely quite resource-intensive and wasteful, and I've been itching to get away from webpack and toward something simpler / more efficient like esbuild/vite for a while now. Unfortunately I have a feeling that replacing webpack completely could be quite an undertaking with a lot of risks and potential unintended side effects, and will likely require relatively intimate familiarity with the code base. So while I appreciate the offer, I think this might be a little bit too much for a first-time contributor 😅

Totally understand, y'all know your code the best! Lmk if I can help in anyway, even if that's just testing, creating an issue with details and tasks, etc. I might fork and mess around with too just for fun 😊

@MaKleSoft
Copy link
Collaborator

Thanks for understanding 😊 not trying to gate-keep or anything just want to save you the frustration of dealing with all the nitty-gritty details of our build pipeline. You can still give it a shot of course, just be aware that it might be tricker than expected and I can't guarantee that your efforts will result in something mergeable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants