首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >EventEmitter内存泄漏

EventEmitter内存泄漏
EN

Stack Overflow用户
提问于 2014-10-25 23:46:41
回答 1查看 246关注 0票数 1

我用的是流星。我构建了一个meteor包,它有助于将文件上传到blob存储。我得到以下错误。此错误仅在5次中出现一次。

代码语言:javascript
复制
W20141025-15:22:40.195(5.5)? (STDERR) (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
W20141025-15:22:40.546(5.5)? (STDERR) Trace
W20141025-15:22:40.546(5.5)? (STDERR)     at addListener (events.js:160:15)
W20141025-15:22:40.546(5.5)? (STDERR)     at /Users/user/boutfeeds/packages/jamesfebin:azure-blob-upload/.build.jamesfebin:azure-blob-upload/npm/node_modules/azure-storage/lib/common/services/storageserviceclient.js:399:31
W20141025-15:22:40.547(5.5)? (STDERR)     at /Users/user/boutfeeds/packages/jamesfebin:azure-blob-upload/.build.jamesfebin:azure-blob-upload/npm/node_modules/azure-storage/lib/common/services/storageserviceclient.js:516:5
W20141025-15:22:40.547(5.5)? (STDERR)     at SharedKey.signRequest (/Users/user/boutfeeds/packages/jamesfebin:azure-blob-upload/.build.jamesfebin:azure-blob-upload/npm/node_modules/azure-storage/lib/common/signing/sharedkey.js:81:3)
W20141025-15:22:40.547(5.5)? (STDERR)     at Object.StorageServiceClient._buildRequestOptions (/Users/user/boutfeeds/packages/jamesfebin:azure-blob-upload/.build.jamesfebin:azure-blob-upload/npm/node_modules/azure-storage/lib/common/services/storageserviceclient.js:498:27)
W20141025-15:22:40.634(5.5)? (STDERR)     at operation (/Users/user/boutfeeds/packages/jamesfebin:azure-blob-upload/.build.jamesfebin:azure-blob-upload/npm/node_modules/azure-storage/lib/common/services/storageserviceclient.js:255:10)
W20141025-15:22:40.634(5.5)? (STDERR)     at func [as _onTimeout] (/Users/user/boutfeeds/packages/jamesfebin:azure-blob-upload/.build.jamesfebin:azure-blob-upload/npm/node_modules/azure-storage/lib/common/services/storageserviceclient.js:422:11)
W20141025-15:22:40.635(5.5)? (STDERR)     at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

代码在这里

代码语言:javascript
复制
 azureUpload:function(fileName,accountName,key,container,callback) {

      var buffer = new Buffer(this.data);
      retryOperations = new azure.ExponentialRetryPolicyFilter();
      blobService = azure.createBlobService(accountName, key).withFilter(retryOperations);
      var blockId = this.blockArray[this.blockArray.length-1];
      var stream = new ReadableStreamBuffer(buffer);
      var self = this;
      Future = Npm.require('fibers/future');
      var myFuture = new Future;


      blobService.createBlockFromStream(blockId,container,fileName,stream,stream.size(),function(err,response)
            {

                if(err)
                {
                    myFuture.return();
                }
                else if (response)
                {     


                 if (self.bytesUploaded+self.data.length >= self.size)
                    {
                         blobService.commitBlocks(container, fileName, {LatestBlocks: self.blockArray}, function(error, result){
                                if(error){
                                 myFuture.return();

                                } else {
                                    myFuture.return({url:"https://"+accountName+".blob.core.windows.net/"+container+"/"+fileName});
                                }
                            });



                    }
                    else
                    {
                         myFuture.return();
                    }


                }

            });

        return myFuture.wait();



      }

你可以在这里查看完整的源代码(向下滚动到azureUpload https://github.com/jamesfebin/azure-blob-upload/blob/master/azureupload.js )

EN

回答 1

Stack Overflow用户

发布于 2014-10-26 03:35:57

节点默认有10个事件发射器。通过向http服务器发出15个并发请求,这可以很容易地超载。这可以通过设置process.setMaxListeners(0)来停止。所以它不会显示错误..有关更多信息,请单击此处http://nodejs.org/api/events.html

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26564225

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档