我的Node.JS脚本响应此错误:
错误:永远检测到的脚本被信号杀死:SIGKILL错误: 脚本重新启动尝试#15
前几个GC:
[11266:0x2890040] 75587毫秒:标记扫描1363.8(1424.5)-> 1363.5 (1423.5)MB,1341.2 / 4.2 ms(平均mu = 0.168,当前mu = 0.119) 分配失败清除可能不会成功[11266:0x2890040] 75605 毫秒:Scavenge 1364.1(1423.5)-> 1363.8(1424.0)MB,11.4 / 0.0毫秒 (平均亩= 0.168,当前亩= 0.119)分配失败 [11266:0x2890040] 75621 ms:清除1364.4(1424.0)-> 1364.2 (1425.0)MB,10.6 / 0.0毫秒(平均亩= 0.168,当前亩= 0.119) 分配失败
JS stacktrace
==== JS stack trace =========================================
0: ExitFrame [pc: 0x2b010e34fb5d]
1: StubFrame [pc: 0x2b010e350eca]
Security context: 0x17ee2c91d969 2: normalizeString(aka normalizeString) [0x47fafaaaf01] [path.js:~57] [pc=0x2b010e58d424](this=0x2202476025b1 ,0x3086a38e3169 ,0x220247602801 ,0x10ca23627b19 ,0x047fafaaaf41 ) 3: /* anonymous */(aka...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 0x90af00 node::Abort() [node] 2: 0x90af4c [node] 3: 0xb05f9e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node] 4: 0xb061d4 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node] 5: 0xf0c6f2 [node] 6: 0xf0c7f8 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [node] 7: 0xf18f88 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node] 8: 0xf19b1b v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node] 9: 0xf1c851 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [node] 10: 0xee6834 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [node] 11: 0x11a0672 v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [node] 12: 0x2b010e34fb5d Aborted (core dumped)
答案 0 :(得分:0)
let express = require('express');
let app = express();
let server = require('http').Server(app);
let io = require('socket.io')(server);
class MyEmitter extends EventEmitter {}
const emitter = new MyEmitter();
emitter.setMaxListeners(emitter.getMaxListeners() + 1);
emitter.once('event', () => {
// do stuff
emitter.setMaxListeners(Math.max(emitter.getMaxListeners() - 1, 0));
});
app.use(express.static('public'));
app.get('/send', function(req, res) {
res.status(200).send('hola mundo!');
});
let sms = [];
io.on('connection', function(socket) {
console.log('alguien se a conectado con sockets');
socket.on('newMessage', function(data) {
sms.push(data);
io.sockets.emit('messages', sms);
});
socket.on('UserRes', function(data) {
io.sockets.emit('UserRespnse', data);
});
socket.on('detectUser', function(data) {
io.sockets.emit('user', data);
});
socket.on('admin_notification', function(data) {
io.sockets.emit('admin_notification', data);
});
});
server.listen('3000', function() {
console.log('servidor corriendo en http://localhost:3000/');
});
答案 1 :(得分:0)
此致命错误发生的两个可能原因
或者如果您确实正在使用庞大的数据集,并且该数据集的大小已经超过节点脚本可以处理的文件大小的标准限制,那么您可以使用以下命令覆盖已处理的默认内存大小按节点脚本。
node --max-old-space-size=myFileSize myFile.js
示例
node --max-old-space-size=4096 myFile.js