因此,我试图将我的项目部署到AWS LightSail实例中。
错误:
<--- JS stacktrace --->
FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed -
JavaScript heap out of memory
1: 0xa222f0 node::Abort() [node]
2: 0x96411f node::FatalError(char const*, char const*) [node]
3: 0xb97f1e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool)
[node]
4: 0xb98297 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char
const*, bool) [node]
5: 0xd52fd5 [node]
6: 0xd83bbe v8::internal::EvacuateNewSpaceVisitor::Visit(v8::internal::HeapObject,
int) [node]
7: 0xd8fbf6 v8::internal::FullEvacuator::RawEvacuatePage(v8::internal::MemoryChunk*,
long*) [node]
8: 0xd7bd8f v8::internal::Evacuator::EvacuatePage(v8::internal::MemoryChunk*) [node]
9: 0xd7c008 v8::internal::PageEvacuationTask::RunInParallel(v8::internal::ItemParallelJob::Task::Runner) [node]
10: 0xd6e8e9 v8::internal::ItemParallelJob::Run() [node]
11: 0xd91b50 void v8::internal::MarkCompactCollectorBase::CreateAndExecuteEvacuationTasks<v8::internal::FullEvacuator, v8::internal::Mar
kCompactCollector>(v8::internal::MarkCompactCollector*, v8::internal::ItemParallelJob*, v8::internal::MigrationObserver*, long) [node]
12: 0xd923ec v8::internal::MarkCompactCollector::EvacuatePagesInParallel() [node]
13: 0xd925b5 v8::internal::MarkCompactCollector::Evacuate() [node]
14: 0xda45b1 v8::internal::MarkCompactCollector::CollectGarbage() [node]
15: 0xd60878 v8::internal::Heap::MarkCompact() [node]
16: 0xd62368 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlag
s) [node]
17: 0xd657ac v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v
8::internal::AllocationAlignment) [node]
18: 0xd33e5b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
19: 0x107c5af v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
20: 0x1423279 [node]
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gui@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gui@0.1.0 start 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! /home/bitnami/.npm/_logs/2021-07-28T21_07_20_268Z-debug.log因此,我调查了这个错误,其中大多数使用了:
export NODE_OPTIONS=--max_old_space_size=4096因此,好的一面不是在设置空间大小之后没有错误,而是坏的一面是它仍然停留在:
> gui@0.1.0 start /opt/bitnami/apache/htdocs/GeThaText/frontend/gui
> react-scripts start
Starting the development server...我的package.json:
{
"name": "gui",
"version": "0.1.0",
"private": true,
"dependencies": {
"@ant-design/icons": "^4.2.1",
"@material-ui/core": "^4.11.2",
"@material-ui/icons": "^4.11.2",
"ant-design": "^1.0.0",
"antd": "^4.7.0",
"axios": "^0.21.1",
"bootstrap": "^4.5.2",
"dotenv": "^10.0.0",
"material-table": "^1.69.2",
"node-sass": "^4.14.1",
"react": "^16.14.0",
"react-copy-to-clipboard": "^5.0.2",
"react-dom": "^16.13.1",
"react-facebook-login": "^4.1.1",
"react-google-login": "^5.2.2",
"react-google-recaptcha": "^2.1.0",
"react-redux": "^7.2.1",
"react-router-config": "^5.1.1",
"react-router-dom": "^5.2.0",
"react-scripts": "^3.4.2",
"react-text-loop": "^2.3.0",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"eslint": "^6.6.0",
"eslint-plugin-react": "^7.24.0",
"less-loader": "^6.2.0",
"sass": "^1.34.1",
"sass-loader": "^11.1.1"
}
}知道有什么问题吗?(在我的电脑Macbook M1上,它能工作)。我试着使用一个简单的react项目,它运行得非常完美
发布于 2021-07-31 19:09:55
我的结论
您可能会收到运行时错误,而且由于您在lightsail上运行,这些错误可能会在某个地方,而不是在您的控制台上。
为什么我说
我在本地下载并安装了您的回购(w10h wsl1)。安装进行得很好,但在运行时,我遇到了错误,因为文件树中的文件夹名是小写的,所以Components或Containers中的任何Containers都失败了。完成整个项目后,查找和替换两个文件夹名称后,项目将按预期启动。
干杯
发布于 2021-12-22 11:46:58
虽然我对AWS的相关细节缺乏洞察力,但这种行为似乎是内存饥饿的典型例子。基本上,当内存使用量接近极限时,性能将在系统交换或尝试GC时缓慢停止(这可能是冻结或挂起的)。
维基百科提供了一个关于如何通过虚拟内存/交换来实现这一点的简略条目:
当系统内存对当前任务高度不足,并且大部分内存活动经过缓慢的交换时,即使CPU处于空闲状态,系统也可能几乎无法执行任何任务。当每个进程都在等待交换时,系统被认为处于交换死亡状态。由于错误配置的内存过度承诺,可能会发生交换死亡。关于“交换到死亡”问题的最初描述与X服务器有关。如果X服务器用于响应击键的代码或数据不在主内存中,那么如果用户输入击键,服务器将出现一个或多个页面错误,需要在处理击键之前从交换区读取这些页,从而减缓对该页的响应。如果这些页面不留在内存中,它们将不得不再次出现故障才能处理下一个击键,这使得系统实际上没有响应,即使它实际上正在正常执行其他任务。
您的选项要么减少内存使用量,要么为任务提供额外内存。
https://stackoverflow.com/questions/68567598
复制相似问题