gpt4 book ai didi

node.js - react native - fatal error : Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

转载 作者:太空宇宙 更新时间:2023-11-03 22:21:52 25 4
gpt4 key购买 nike

我正在努力使用 React Nativeaws-sdk。我使用 aws-sdk 而不是 aws-amplify 的原因是:

aws-amplify does not support Using a pre-signed URL to upload a file

npm 安装 aws-sdk 并导入 aws-sdk-react-native 之前,我的项目工作正常(此文件当 aws-sdk 版本为“2.369.0”时为 4.3MB)。

添加这行代码后:

const AWS = require("aws-sdk/dist/aws-sdk-react-native");

应用程序崩溃并显示错误消息:

transform[stdout]: <--- Last few GCs --->
transform[stdout]:
transform[stdout]: [5433:0x103800000] 59176 ms: Mark-sweep 1256.2 (1442.0) -> 1236.2 (1434.5) MB, 3855.9 / 0.0 ms (average mu = 0.239, current mu = 0.130) allocation failure scavenge might not succeed
transform[stdout]: [5433:0x103800000] 63390 ms: Mark-sweep 1259.8 (1442.5) -> 1243.1 (1438.5) MB, 3924.9 / 0.0 ms (average mu = 0.161, current mu = 0.069) allocation failure scavenge might not succeed
transform[stdout]:
transform[stdout]:
transform[stdout]: <--- JS stacktrace --->
transform[stdout]:
transform[stdout]: ==== JS stack trace =========================================
transform[stdout]:
transform[stdout]: 0: ExitFrame [pc: 0x1e49a5a5be3d]
transform[stdout]: Security context: 0x21d5cac9e6e1 <JSObject>
transform[stdout]: 1: queue [0x21d5c3f5fc09] [/Users/yumac/Projects/ReactNative/Demo/OutOfMemory/node_modules/@babel/generator/lib/buffer.js:~88] [pc=0x1e49a5f9825e](this=0x21d55e682309 <Buffer map = 0x21d51ca6ba29>,str=0x21d577355491 <String[12]: >)
transform[stdout]: 2: StringLiteral [0x21d5c3f07491] [/Users/yumac/Projects/ReactNative/Demo/OutOfMemory/node_modules/@babel/ge...
transform[stdout]:
transform[stderr]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
transform[stderr]: 1: 0x10003ae75 node::Abort() [/usr/local/bin/node]
transform[stderr]: 2: 0x10003b07f node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
transform[stderr]: 3: 0x1001a7ae5 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
transform[stderr]: 4: 0x100572ef2 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
transform[stderr]: 5: 0x1005759c5 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/usr/local/bin/node]
transform[stderr]: 6: 0x10057186f v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
transform[stderr]: 7: 0x10056fa44 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
transform[stderr]: 8: 0x10057c2dc v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
transform[stderr]: 9: 0x10057c35f v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
transform[stderr]: 10: 0x10054bca4 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/usr/local/bin/node]
transform[stderr]: 11: 0x1007d3b54 v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
transform[stderr]: 12: 0x1e49a5a5be3d
transform[stderr]: 13: 0x1e49a5f9825e
transform[stderr]: 14: 0x1e49a5f84e0f
transform[stderr]: 15: 0x1e49a5a0a5c3
transform[stderr]: 16: 0x1e49a5ee8a79

我尝试了很多解决方案,例如:

increase-memory-limit

node --max-old-space-size=8192 index.js

如果您尝试了这些解决方案并且有效,请告诉我。也许我做错了什么

如果您有任何建议,我随时乐意听取您的意见。

提前谢谢您!

最佳答案

我可以通过将 package.json 更改为来运行调试:

"scripts": {
...
"start-max": "node --max-old-space-size=8192 node_modules/react-native/local-cli/cli.js start",
...
},

在终端运行:“npm run start-max”以 8,192 MB 启动 Node 服务器。然后正常运行您的项目:“react-native run-android”。

Android 版本:

在应用程序 build.gradle 文件中,添加此行

project.ext.react = [
entryFile: "index.js",
nodeExecutableAndArgs: ["node", "--max-old-space-size=8192"]
]

享受吧!

关于node.js - react native - fatal error : Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53609653/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com