C# Azure功能-nodejs和dot net core 2.2内存消耗持续增长,直到回收

C# Azure功能-nodejs和dot net core 2.2内存消耗持续增长,直到回收,c#,node.js,azure-functions,asp.net-core-2.2,csx,C#,Node.js,Azure Functions,Asp.net Core 2.2,Csx,我有一个简单的http触发的azure函数,它从azure sql数据库检索标量值并以json形式返回,该函数使用azure应用程序服务计划托管,我尝试了“dot net core 2.2应用程序包”和“nodejs”它们都使内存消耗随着时间的推移不断增长,直到内存达到90%或100%以上,然后要么GC开始工作,要么应用程序被回收。我不知道是哪一种情况发生了,但之后内存恢复正常并开始再次增长。奇怪的是,我尝试了与csharp脚本相同的dotnetcore2.2代码,在这种情况下,它工作正常,内存

我有一个简单的http触发的azure函数,它从azure sql数据库检索标量值并以json形式返回,该函数使用azure应用程序服务计划托管,我尝试了“dot net core 2.2应用程序包”和“nodejs”它们都使内存消耗随着时间的推移不断增长,直到内存达到90%或100%以上,然后要么GC开始工作,要么应用程序被回收。我不知道是哪一种情况发生了,但之后内存恢复正常并开始再次增长。奇怪的是,我尝试了与csharp脚本相同的dotnetcore2.2代码,在这种情况下,它工作正常,内存从未增长过

有人能解释一下dotnetcore应用程序和CSX内存消耗之间的区别吗

在所有情况下,我都使用x64环境

如果您知道如何转储应用程序服务中托管的特定azure功能的内存,这将非常有用

使用Microsoft.AspNetCore.Http;
使用Microsoft.AspNetCore.Mvc;
使用Microsoft.Azure.WebJobs;
使用Microsoft.Azure.WebJobs.Extensions.Http;
使用Microsoft.Extensions.Configuration;
使用Microsoft.Extensions.Logging;
使用制度;
使用System.Data.SqlClient;
使用System.Threading.Tasks;
名称空间MyNamespace
{
公共静态类GetNumber
{
[函数名(“GetNumber”)]
公共静态异步任务运行([HttpTrigger(AuthorizationLevel.Anonymous,“get”,Route=null)]HttpRequest请求、ILogger日志、ExecutionContext上下文)
{
LogInformation(“C#HTTP触发器函数处理了一个请求。”);
尝试
{
字符串代码=请求查询[“代码”];
if(code.Equals(“123”)==false)
{
返回新的BadRequestObjectResult(“无效的API调用!”);
}
if(int.TryParse(请求查询[“id”],out int id)==false)
{
返回新的BadRequestObjectResult(“无效Id!”);
}
var config=new ConfigurationBuilder()
.SetBasePath(context.FunctionAppDirectory)
.AddJsonFile(“local.settings.json”,可选:true,重载更改:true)
.AddenEnvironmentVariables()
.Build();
var connString=config.GetSection(“ConnectionString”).GetSection(“MyDBConnectionString”).Value;
整数=0;
使用(var sqlConnection=newsqlconnection(connString))
{
使用(var sqlCommand=sqlConnection.CreateCommand())
{
sqlCommand.CommandType=System.Data.CommandType.StoredProcess;
sqlCommand.CommandText=“GetNumber”;
sqlCommand.Parameters.AddWithValue(“Id”,Id);
sqlConnection.Open();
number=(int)等待sqlCommand.ExecuteScalarAsync();
Dispose();
sqlConnection.Close();
}
}
var result=新的ContentResult();
result.Content=“{\“number\”:“+number+”}”;
result.ContentType=“应用程序/json”;
result.StatusCode=StatusCodes.Status200OK;
返回结果;
}
捕获(例外情况除外)
{
log.LogError(例如消息,例如);
返回(ActionResult)新的OkObjectResult(新的{number=0});
}
}
}
}

使用ProcDump.exe手动收集内存转储

有关更多信息,请访问博客: