title: aws ec2 tsc javascript heap out of memory
body: <p>I am currently deploying a Node.js server using AWS EC2 t2.micro, Docker.</p>
  <p>I build a typescript file with <code>tsc</code> and try to run the built file directly.</p>
  <p>However, at the time of using the tsc command, a javascript heap out of memory error occurs.</p>
  <pre><code>&lt;--- Last few GCs ---&gt;
  lo[29:0x5f661f0]    18203 ms: Mark-sweep (reduce) 489.2 (491.1) -&gt; 488.3 (492.4) MB, 709.8 / 0.0 ms  (+ 0.1 ms in 16 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 728 ms) (average mu = 0.243, current mu = 0.025) allocati[29:0x5f661f0]    18935 ms: Mark-sweep (reduce) 489.4 (491.4) -&gt; 488.8 (492.9) MB, 713.0 / 0.0 ms  (+ 0.1 ms in 17 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 732 ms) (average mu = 0.139, current mu = 0.026) allocati
  
  &lt;--- JS stacktrace ---&gt;
  
  FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
   1: 0xa04200 node::Abort() [node]
   2: 0x94e4e9 node::FatalError(char const*, char const*) [node]
   3: 0xb7978e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
   4: 0xb79b07 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
   5: 0xd34395  [node]
   6: 0xd64f2e v8::internal::EvacuateNewSpaceVisitor::Visit(v8::internal::HeapObject, int) [node]
   7: 0xd70f66 v8::internal::FullEvacuator::RawEvacuatePage(v8::internal::MemoryChunk*, long*) [node]
   8: 0xd5d14f v8::internal::Evacuator::EvacuatePage(v8::internal::MemoryChunk*) [node]
   9: 0xd5d3c8 v8::internal::PageEvacuationTask::RunInParallel(v8::internal::ItemParallelJob::Task::Runner) [node]
  10: 0xd4fca9 v8::internal::ItemParallelJob::Run() [node]
  11: 0xd72ec0 void v8::internal::MarkCompactCollectorBase::CreateAndExecuteEvacuationTasks&lt;v8::internal::FullEvacuator, v8::internal::MarkCompactCollector&gt;(v8::internal::MarkCompactCollector*, v8::internal::ItemParallelJob*, v8::internal::MigrationObserver*, long) [node]
  12: 0xd7375c v8::internal::MarkCompactCollector::EvacuatePagesInParallel() [node]
  13: 0xd73925 v8::internal::MarkCompactCollector::Evacuate() [node]
  14: 0xd85911 v8::internal::MarkCompactCollector::CollectGarbage() [node]
  15: 0xd41c38 v8::internal::Heap::MarkCompact() [node]
  16: 0xd43728 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
  17: 0xd46b6c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
  18: 0xd0c472 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [node]
  19: 0xd086c2 v8::internal::FactoryBase&lt;v8::internal::Factory&gt;::AllocateRawArray(int, v8::internal::AllocationType) [node]
  20: 0xd08774 v8::internal::FactoryBase&lt;v8::internal::Factory&gt;::NewFixedArrayWithFiller(v8::internal::Handle&lt;v8::internal::Map&gt;, int, v8::internal::Handle&lt;v8::internal::Oddball&gt;, v8::internal::AllocationType) [node]
  21: 0xf4ef4b v8::internal::OrderedHashTable&lt;v8::internal::OrderedHashSet, 1&gt;::Allocate(v8::internal::Isolate*, int, v8::internal::AllocationType) [node]
  22: 0xf4f0df v8::internal::OrderedHashTable&lt;v8::internal::OrderedHashSet, 1&gt;::Rehash(v8::internal::Isolate*, v8::internal::Handle&lt;v8::internal::OrderedHashSet&gt;, int) [node]
  23: 0x103eb98 v8::internal::Runtime_SetGrow(int, unsigned long*, v8::internal::Isolate*) [node]
  24: 0x1401219  [node]
  Aborted (core dumped)
  npm ERR! code ELIFECYCLE
  npm ERR! errno 134
  npm ERR! share_up@1.0.0 build: `rimraf dist &amp;&amp; tsc -p tsconfig.json`
  npm ERR! Exit status 134
  npm ERR! 
  npm ERR! Failed at the share_up@1.0.0 build script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     /root/.npm/_logs/2021-04-09T02_15_25_430Z-debug.log
  </code></pre>
  <p>This is error message</p>
  <p>How can I fix this?</p>