在进程天蓝色索引中逐渐累积RAM内存

时间:2019-07-15 09:44:38

标签: c#

我正在开发一个索引Azure应用程序,大约每30秒一次,它读取一个DB并上传文档,但是RAM内存持续增长。我确定贡献更大的方法是在上传文档中。我向我保证,从流程的开始到最终,Azure只能与Azure建立联系(不会创建更多的类)。

使用带有c#的Visual Studio 2017框架。 Windows 10. Azure搜索API版本9.0.1。

private EscribeSearchAzure(string searchServiceName, string adminApiKey, string nombreIndexador)
        {
            clienteDeServicio = new SearchServiceClient(searchServiceName, new SearchCredentials(adminApiKey));
            clienteDeIndexacion = new SearchIndexClient(searchServiceName, nombreIndexador, new SearchCredentials(adminApiKey));
            _nombreIndexador = nombreIndexador;
        }
public DocumentIndexResult CargarRegistrosIndixadorTablaVideo(List<TablaParaIndexar> registroTablaVideo)
    {
        DocumentIndexResult resultado = null;           
            var batch = IndexBatch.Upload(registroTablaVideo);
            if (registroTablaVideo.Count != 0)
                resultado = clienteDeIndexacion.Documents.Index(batch);        

        return resultado;
    }

我不知道如何清理RAM内存。对象SearchServiceClient和SearchIndexClient的Dispose方法没有用,因为您在使用包含clientIndexation.Dispose();的方法之前和之后绘制了RAM消耗图。结果更糟,因为使用后必须建立新的连接。 每分钟内存的增长大约由以下方程式组成:0,0056x + 116,78。 (非常近似!) 因此,在三天内,它从67 MB增加到150 MB。该过程永远不会停止,因此,当您累积多达400 MB的RAM时,时间就到了。

在循环主体过程的最后阶段,我通过以下方式使用了垃圾回收器:

public void LimpiarConexion()
        {
            clienteDeServicio.Dispose();
            clienteDeIndexacion.Dispose();
            GC.Collect();
            instancia = null;
        }

我显示了使用“ LimpiarConexion”(橙色)和不使用“ LimpiarConexion”(蓝色)功能的过程中消耗RAM内存的结果。 Consume RAM memory Graph

此图只有10分钟,但这是趋势。

0 个答案:

没有答案