跟踪涉及流星和多个DDP连接的内存泄漏

我有一个由多个运行Meteor v1.5.4.2的“节点”组成的网络(由于依赖关系)。这些节点中的每一个都应该能够与其他节点通信以获取统计信息等。这是通过在应该从其他节点获取信息的节点上使用Meteors ddp客户端服务器端完成的。

这看似效果很好,但是当我们通过网络中的许多变化来激怒它时(意味着大量的连接来去去去),内存逐渐建立起来,直到冻结并掉落。我对解决内存泄漏的经验有限,但是通过查看堆快照,我发现有一个名为“ Connection”的对象的堆积(粘贴在下面)。在字符串下,我还找到了很多包含DDP连接中使用的证书和CRL的字符串,这使我相信我的代码中涉及连接处理的问题。香港专业教育学院试图列出下面的要点,删除了很多次要逻辑。

在进一步处理这个问题上,我有点茫然,因此任何建议,想法或想法都将受到欢迎。

谢谢。

此处压缩了其连接方式

if(Meteor.isServer) {
    connectionHandler = new DDPConnectionHandler();
    Meteor.setInterval( () => connectionHandler.checkNodeConnections(),5000);
}
export const DDPConnectionHandler = function() {
    this.connections = [];

    this.checkNodeConnections = () => {
        // Logic to add or remove the node connections in this.connections
        // Looping pr. node to handle
        const node = {...} // Details of the node to add/remove

        // Add new conncetion
        this.connections.push( new DDPConnection(node) );

        // Remove connection
        const index = currentConnections.indexOf(node.id);
        this.connections[index].disconnect();
        this.connections.splice(index,1);
    };

}
export const DDPConnection = function(node) {
    let self = this;

    // setting up variables to use,pw,user,url ... etc. 

    this.connection = DDP.connect(url,{ /* certs etc. for SSL */ });

    this.connection.call("login",{/* login details */},(error,result) => {
        if( !error ) {
            // Wrap in timeout to space out the stats calls
            Meteor.setTimeout( () => { self.initNodeStats(); },randomNumber );
        } else { /* No luck */ }
    });

    this.disconnect = () => {
        this.connection.disconnect(); // also tried with .close()
    };

    this.subscribe = (collection) => {
        // function to fetch other data
    };

    // Initialize and start recieving default basis ndoestats from current external nde
    this.initNodeStats = () => { this.getStats(); };

    this.getStats = () => {
        self.connection.call('getStats',{},result) => {
            if( error ) { /* No luck */
            } else if ( result ) { /* Pass data to handlers */ }
        });
    }

}
Connection
    _stream::ClientStream
    __proto__::Object
    _outstandingMethodBlocks::Array
    __flushBufferedWrites::()
    map::system / Map
    _methodInvokers::Object
    properties::(object properties)[]
    _bufferedWritesFlushAt::system / Oddball
    _bufferedWritesFlushHandle::system / Oddball
    _lastSessionId::system / Oddball
    _retryMigrate::system / Oddball
    _userId::system / Oddball
    _version::system / Oddball
    _versionSuggestion::system / Oddball
    onReconnect::system / Oddball
    _supportedDDPVersions::Array
    _userIdDeps::Tracker.Dependency
    _bufferedWrites::Object
    _documentsWrittenByStub::Object
    _methodHandlers::Object
    _methodsBlockingQuiescence::Object
    _serverDocuments::Object
    _stores::Object
    _subsBeingRevived::Object
    _subscriptions::Object
    _updatesForUnknownStores::Object
    _afterupdateCallbacks::Array
    _messagesBufferedUntilQuiescence::Array
    _resetStores::system / Oddball

在挖掘更多内容后进行更新。

我似乎在Connection对象的“ _outstandingMethodBlocks”属性中积累了“方法”。此处在第129行定义: https://github.com/meteor/meteor/blob/release-1.5.4.2/packages/ddp-client/livedata_connection.js#L129

也许有一些超时设置可以用来阻止它们存储在那里?

kukuming 回答:跟踪涉及流星和多个DDP连接的内存泄漏

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3153231.html

大家都在问