在ubuntu上,expo publish总是以Javascript结尾

问题描述

我有一台运行Ubuntu 16.0.0 RAM的Ubuntu 20.04.1 LTS的PC。我正在尝试构建EXPO React应用的APK。每当我尝试运行expo publish --release-channel channel_name时,它总是会耗尽内存并为我提供以下堆栈跟踪:

transform[stdout]: ==== JS stack trace =========================================
transform[stdout]:
transform[stdout]:     0: ExitFrame [pc: 0x13cf099]
transform[stdout]: Security context: 0x1ec3465408d1 <JSObject>
transform[stdout]:     1: token(aka token) [0x2ac37c202af1] [0x0acc333004b1 <undefined>:~1916] [pc=0x1ca847032d11](this=0x0acc333004b1 <undefined>,0x158b955c4321 <String[#4]: punc>,0x285cf488fc21 <String[#1]: :>,0x0acc333004b1 <undefined>)
transform[stdout]:     2: next_token [0x2ac37c200119] [0x0acc333004b1 <undefined>:~2287] [pc=0x1ca846a7bc0c](this=0x2ac37c200159 <Object map = 0x1cca2bdcb39>,0x0ac...
transform[stdout]:
transform[stderr]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
transform[stderr]:  1: 0xa093f0 node::Abort() [/usr/bin/node]
transform[stderr]:  2: 0xa097fc node::OnFatalError(char const*,char const*) [/usr/bin/node]
transform[stderr]:  3: 0xb8431e v8::Utils::ReportOOMFailure(v8::internal::Isolate*,char const*,bool) [/usr/bin/node]
transform[stderr]:  4: 0xb84699 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*,bool) [/usr/bin/node]
transform[stderr]:  5: 0xd31055  [/usr/bin/node]
transform[stderr]:  6: 0xd316e6 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/bin/node]
transform[stderr]:  7: 0xd3df65 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector,v8::GCCallbackFlags) [/usr/bin/node]
transform[stderr]:  8: 0xd3ee15 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace,v8::internal::GarbageCollectionReason,v8::GCCallbackFlags) [/usr/bin/node]
transform[stderr]:  9: 0xd418cc v8::internal::Heap::AllocateRawWithRetryOrFail(int,v8::internal::AllocationType,v8::internal::AllocationOrigin,v8::internal::AllocationAlignment) [/usr/bin/node]
transform[stderr]: 10: 0xd0837b v8::internal::Factory::NewFillerObject(int,bool,v8::internal::AllocationOrigin) [/usr/bin/node]
transform[stderr]: 11: 0x1049fbe v8::internal::Runtime_AllocateInYoungGeneration(int,unsigned long*,v8::internal::Isolate*) [/usr/bin/node]
transform[stderr]: 12: 0x13cf099  [/usr/bin/node]

我尝试设置NODE_OPTIONS =-max_old_space_size = 8192,然后在运行v8.getHeapStatistics()时看到以下结果:

{
  total_heap_size: 5173248,total_heap_size_executable: 524288,total_physical_size: 4460520,total_available_size: 8636951928,used_heap_size: 3019200,heap_size_limit: 8640266240,malloced_memory: 8192,peak_malloced_memory: 712992,does_zap_garbage: 0,number_of_native_contexts: 1,number_of_detached_contexts: 0
}

即使将max_old_space_size设置为8 GB,我仍然可以获得相同的堆栈跟踪。

为了确保我的节点选项是否正常运行,我将其更改为NODE_OPTIONS =-max_old_space_size = 4096并获取了它。 v4.ge​​tHeapStatistics()的4GB结果为:

{
  total_heap_size: 5173248,total_physical_size: 4460744,total_available_size: 4342034920,<----- this value changed frmo 8GB to 4GB
  used_heap_size: 3050272,heap_size_limit: 4345298944,<----- this value changed frmo 8GB to 4GB
  malloced_memory: 8192,number_of_detached_contexts: 0
}

我有一台配置类似的MacBook,使用--max_old_space_size = 4096构建APK时没有问题。

我尝试将这些值与MacBook上的值进行比较,它们看起来很相似。然后,我运行v8.getHeapSpaceStatistics()命令。完整的输出在这里:https://paste.ubuntu.com/p/5nvdYVmFRf/。此命令的new_space部分比我的MacBook上的space_size小:

Ubuntu
  {
    space_name: 'new_space',space_size: 1048576,space_used_size: 298808,space_available_size: 748648,physical_space_size: 1014408
  },
MacBook
  {
    space_name: 'new_space',space_size: 2097152,space_used_size: 919712,space_available_size: 127744,physical_space_size: 2060464
  },

我没有任何尝试的想法,有人可以帮助我解决这个问题吗?

节点版本:v12.18.4
Expo cli版本:3.27.12
Expo SDK版本:38

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)