Help getting a build to finish on low memory device

I’m currently behind a very slow 3G network and deployments are a pain.

I decided to setup a VPC to build and deploy my app. Good idea, but the build crashes with out of memory:

=> Started proxy.                             
=> Meteor is available. Update this project with 'meteor update'.
=> Started MongoDB.                           
   Processing files with fourseven:scss ...  \
<--- Last few GCs --->

[31041:0x2a4f7f0]   448140 ms: Mark-sweep 1267.5 (1433.0) -> 1267.5 (1433.0) MB, 899.9 / 0.1 ms  allocation failure GC in old space requested
[31041:0x2a4f7f0]   449024 ms: Mark-sweep 1267.5 (1433.0) -> 1267.5 (1426.0) MB, 884.1 / 0.1 ms  last resort GC in old space requested
[31041:0x2a4f7f0]   449944 ms: Mark-sweep 1267.5 (1426.0) -> 1267.5 (1426.0) MB, 919.8 / 0.2 ms  last resort GC in old space requested

<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0xef2969a5879 <JSObject>
    1: DoJoin(aka DoJoin) [native array.js:~94] [pc=0x3d2d039267d4](this=0xb33018022d1 <undefined>,o=0x31fbc7ed26b9 <JSArray[2017]>,p=2017,D=0xb3301802371 <true>,z=0xb3301802431 <String[0]: >,y=0xb33018023e1 <false>)
    2: Join(aka Join) [native array.js:~119] [pc=0x3d2d034ed4fe](this=0xb33018022d1 <undefined>,o=0x31fbc7ed26b9 <JSArray[2017]>,p=2017,z=0xb3301802431 <String[0]: >,y=0xb33018023e1 ...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

My Meteor version in this case is v1.6.1.4, the VPC has 1Gb of memory, 1Gb of swap disk and 1 low-end cpu, what sort of voodoo tricks should I try to get the Meteor build to finish?

I did try building with TOOL_NODE_FLAGS="--max_old_space_size=512 --no-expose-gc" but it didn’t affect the outcome.

Have you tried increasing TOOL_NODE_FLAGS (rather than decreasing it) and increasing your amount of swap space? The build will be super slow though. You should probably just get an instance with more memory.

I kinda don’t want to, due to the expected slowness. I have however upgraded my instance to 3Gb, I’ll see if I can get the first build through and then decrease the memory after that. Or stick to 3Gb, we’ll see. Any tips are welcome, I’ve heard of CI setups for Meteor running succesfully on 1Gb!

I don’t think your deployment failing is anything to do with your connection speed. It’s simply a case that you need more memory available to node to build it. My app hit further issues after and the memory limit needed upped again to 5gb to get it to build. I think there was an issue in github where it consumes a bit more memory in the latest version but it’s all pretty much down to the minification process using tons of memory.

If you disable the minify package then your app may compile again in 1gb but you obviously won’t get minification. On the plus side it really speeds up the bundling process. Not really an ideal fix for you though.

Me neither: I just explained it was the reason for trying to handle deployments from the VPC instead of my local machine, which sits behind the slow ass network.

It’s definitely a memory issue, and I’d like to solve it!

As an update, I got the build to complete after resizing my VPC to 8Gb of RAM. Downsizing back to 1Gb and the build fails again, so completing the initial build didn’t help.

After the initial build completed, the build didn’t crash even with 1Gb of RAM, it just gets stuck forever, rendering my VPC completely unresponsive.