我正在exceljs中导出800000行-致命错误:无效的数组长度分配失败-JavaScript堆内存不足NodeJS

问题描述

*> [3950:0x4e9b9e0] 1915848 ms:清除5394.1(5861.9)-> 5386.2

(5861.9)MB,12.0 / 0.0 ms(平均亩= 0.933,当前亩= 0.925) 分配失败 [3950:0x4e9b9e0] 1915869 ms:清除5394.4(5861.9)-> 5386.5(5861.9)MB,11.9 / 0.0 ms(平均mu = 0.933,当前mu = 0.925) 分配失败 [3950:0x4e9b9e0] 1915889 ms:清除5394.6(5861.9)-> 5386.7(5861.9)MB,11.7 / 0.0 ms(平均mu = 0.933,当前mu = 0.925) 分配失败

    0: ExitFrame [pc: 0x13da519]
Security context: 0x08de75d40921 <JSObject>
    1: render [0x31fa00a89f09] [/home/ydv/Desktop/larenon/LarenonApi/node_modules/exceljs/lib/xlsx/xform/sheet/cell-xform.js:~197]

[pc = 0xf0cf683583a](this = 0x09a8b99801a9,0x09a8b9980169,0x1b1c280e7299) 2:/ *匿名 /(又名/ 匿名* /)[0x9a8b9980291] [/ home / yd ...

FATAL ERROR: invalid array length Allocation failed - JavaScript heap out of memory
 1: 0xa0e670 node::Abort() [node]
 2: 0xa0ea9c node::OnFatalError(char const*,char const*) [node]
 3: 0xb83afe v8::Utils::ReportOOMFailure(v8::internal::Isolate*,char const*,bool) [node]
 4: 0xb83e79 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*,char

const *,bool)[节点] 5:0xd32305 [节点] 6:0xd0a661 [node] 7:0xd0c342 v8 ::内部::工厂:: NewUninitializedFixedArray(int)[节点] 8:0xe7df9f [node] 9:0xe7e250 [node] 10:0x102dfab v8 :: internal :: Runtime_GrowArrayElements(int,unsigned long *,v8 :: internal :: Isolate *)[节点] 11:0x13da519 [node] 中止(核心已弃用)*

exports.testExcelCreation = async function () {
                const apiResponse = new ApiResponse();
                const fileName = "assets/Uploads/Reports/TEST/test_report_" + (new Date()).getTime() + ".xlsx";
                const workBook = new ExcelJs.Workbook();
                const sheet = workBook.addWorksheet("Slow And Not Moving");
                console.log("Success : Excel Start Creating : ",moment(new Date()).format("YYYY-MM-DD HH:mm:ss"));
                for (let i=1; i <= 800000; i++) {
                    await commonHelper.handleEndLoopTimeout(0);
                    for (let col=1; col <= 10; col++) {
                        sheet.getCell(i,col).value = "Value:"+i+"-"+col;
                    }
                    console.log("EXCEL : ",i);
                }
                console.log("Success : Excel End Creating : ",moment(new Date()).format("YYYY-MM-DD HH:mm:ss"));
                FileSystem.mkdirSync("assets/Uploads/Reports/TEST",{recursive: true});
                await workBook.xlsx.writeFile(fileName).then(
                    Response => {
                        console.log("Success : Excel successfully created !")
                    }
                );
                console.log("Success : Excel End Creating : ",moment(new Date()).format("YYYY-MM-DD HH:mm:ss"));
                console.log("FileName : ",fileName);
                apiResponse.opcode = 1;
                apiResponse.numRows = 100;
                apiResponse.data = [fileName];
                apiResponse.message = "Report data available";
                return apiResponse;        
            }

解决方法

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

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

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

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...