nodejs readline,JavaScript heap out of memory
来源:互联网 发布:淘宝店发货地址和退货 编辑:程序博客网 时间:2024/06/05 23:15
用node读取3个很大的日志文件,每个大约200M,然后逐行处理,测试了两种方法。
第一种
fs.readFileSync(“aa.log").toString().split('\n');
就是先全部读取处理来,然后切分成数组,之后单独处理数组的每一条数据,处理3个文件,花了20秒,在测试的过程中出现了
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
这个错误,不过我修改程序调好了。
第二种
const rd = readline.createInterface({
input: fs.createReadStream(file),
output: process.stdout,
terminal: false
});
rd.on('line', function(item) {
//处理
}).on("close",()=>{
//处理
});
就是独行读取出来,都行处理
处理3个文件,花了不到16秒。
看来这种问题还是readline比较快,并且readline不会有JavaScript heap out of memory的错误
阅读全文
0 0
- nodejs readline,JavaScript heap out of memory
- webpack打包报javaScript heap out of memory的解决方法
- davlik heap out of memory
- Java heap out of memory
- java heap out of memory分析
- Tomcat 5.5 java heap stack out of memory solution
- 报错:out of memory java heap space
- out of memory
- Out of memory
- out of memory
- android out of memory
- out of memory
- MATLAB: OUT OF MEMORY
- MATLAB out of memory
- 解决out of memory
- Out Of Memory
- android Out of memory
- linux out of memory
- 创业日志(十六) 员工招聘和离职
- win10 家庭版cmd命令打开超级管理员和关闭超级管理员
- Vector原理讲解
- Android群英传学习——第七章、Android动画机制与使用技巧
- 深入理解javascript原型和闭包(15)——闭包
- nodejs readline,JavaScript heap out of memory
- servlet request getHeader("x-forwarded-for") 获取真实IP
- 文章标题
- clearfix的用法
- Redraiment猜想
- Servlet面试常考题
- 029、包的概述和讲解
- JavaScript中的五种基本数据类型详解
- Linux下32位环境的用户空间内存分布情况