作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我将文件上传到 Azure Blob 时,内存消耗似乎相当高。以下数据来自上传的 200 MB 文件。
public async Task<IActionResult> PostFile(IFormFile file)
{
var filePath = Path.GetTempFileName();
using (var stream = new FileStream(filePath, FileMode.Create))
{
-> Memory used: 108 MB
await file.CopyToAsync(stream);
-> Memory used: 308 MB
await blockBlob.UploadFromStreamAsync(stream);
-> Memory used: 988 MB
}
}
由于文件已经加载到流中,我无法理解UploadFromStreamAsync()导致的内存消耗急剧增加。我正在使用 Microsoft.WindowsAzure.Storage 8.1.4 和 .NET Core 1.1。
我做错了什么还是这是预期的行为?
最佳答案
我的测试应用程序是MVC应用程序,因此只需要243内存使用量。
Web api 应用程序与 MVC 应用程序内存使用情况不同。
我的 Web api 应用程序使用量为 1G,如下图所示:
Am I doing anything wrong or is this expected behavior?
这是预期的行为。
我建议您可以使用快照来查看堆大小变化信息。
可以看到堆大小已释放,但内存使用量仍为 1G。
关于c# - 将文件上传到 Azure Blob 时的 ASP.NET Core 内存消耗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44546073/
我是一名优秀的程序员,十分优秀!