【Azure App Service】在App Service for Windows上验证能占用的内存最大值
问题描述
在创建App Service服务的时候,根据定价层不同,内存使用的最大值也有不同。但在实际测试中,发现内存最大只能占用2GB左右,
而定价层中内存分配明明是大于2GB(比如B3定价层的内存为7GB), 这是一种什么情况呢?

在App Service中Kudu工具上,查看进程分配的内存大小:

问题解答
使用一段简短C#代码来进行验证,代码是一个循环,根据URL中输入的数字,循环创建多个100MB大小的对象.
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
var app = builder.Build(); app.MapGet("/oom/{objs}", (string objs) =>
{
int objunmbers = int.Parse(objs);
try
{
byte[][] largeArray = new byte[objunmbers][];
for (int i = 0; i < objunmbers; i++)
{
largeArray[i] = new byte[1024 * 1024 * 100]; // 每个对象占用100MB
}
return "成功创建大数组对象: " + objs;
}
catch (OutOfMemoryException)
{
return "内存不足,无法创建大数组对象";
}
}); app.Run();
代码本地调试,可以看见应用占用内存直线上涨:

部署到Azure App Service后,同样通过Kudu站点Process信息,发现内存的占用的确只有2GB左右,但请求需要更多内存资源时,页面返回:内存不足,无法创建大数组对象
这是因为App Service for Windows默认使用32位操作系统,最大内存只能分配2GB。
当主动修改位64位后,App Service 内存就可以占用到定价层所允许的最大值!

如B3的定价层在Kudu中查看到w3wp.exe进程分配的内存达到了6GB

根据以上测验,当使用App Service内存没有达到预期的值,且应用异常日志出现OutOfMemory时,就需要检查Platform的设置是否位64bit。
参考资料
I see the message "Worker Process requested recycle due to 'Percent Memory' limit." How do I address this issue?
The maximum available amount of memory for a 32-bit process (even on a 64-bit operating system) is 2 GB. By default, the worker process is set to 32-bit in App Service (for compatibility with legacy web applications).
Consider switching to 64-bit processes so you can take advantage of the additional memory available in your Web Worker role. This triggers a web app restart, so schedule accordingly.
Also note that a 64-bit environment requires a Basic or Standard service plan. Free and Shared plans always run in a 32-bit environment.
【Azure App Service】在App Service for Windows上验证能占用的内存最大值的更多相关文章
- Windows上验证过的一些乱七八糟的笔记
1.Win10安装时报错“windows 无法安装到这个磁盘 gpt分区形式”? 答:shift+f10: https://jingyan.baidu.com/article/08b6a591c82 ...
- windows上使用SecureCRT连接linux
前言: SecureCRT是一款支持SSH(SSH1和SSH2)的终端仿真程序,简单地说是Windows下登录UNIX或Linux服务器主机的软件.这样操作的时候不必进入到linux桌面,可以更方便的 ...
- node-webkit教程(7)Platform Service之APP
node-webkit教程(7)Platform Service之APP 文/玄魂 前言 几个月前,要开发一个简易的展示应用,要求支持离线播放(桌面应用)和在线播放(web应用). 当时第一想到的是f ...
- 【应用服务 App Service】App Service发生错误请求时,如何查看IIS Freb日志,从中得知错误所发生的模块,请求中所携带的Header信息
问题描述 在使用Azure App Service时候,我们有时候对 一些请求发生错误毫无头绪,能从错误代码中知道请求错误,但是更多的信息呢? 当我们需要更多的信息时候,通常有以下的一些方式来查找问题 ...
- android如何实现开机自动启动Service或app
第一步:首先创建一个广播接收者,重构其抽象方法 onReceive(Context context, Intent intent),在其中启动你想要启动的Service或app. import and ...
- [Windows Azure] What is a cloud service?
What is a cloud service? When you create an application and run it in Windows Azure, the code and co ...
- 【转】android如何实现开机自动启动Service或app
1.今天我们主要来探讨android怎么让一个service开机自动启动功能的实现.Android手机在启动的过程中会触发一个Standard Broadcast Action,名字叫android. ...
- 在Azure上部署IPv6的App通过IOS App Store审核
随着中国企业出海Go Global,越来越多的用户开始在Global Azure部署自己的应用.由于对Global Azure功能和文档的不熟悉,使用过程中或多或少遇到了一些坑.事实上呢,这些并不是坑 ...
- 不可或缺 Windows Native (25) - C++: windows app native, android app native, ios app native
[源码下载] 不可或缺 Windows Native (25) - C++: windows app native, android app native, ios app native 作者:web ...
- 004.Create a web app with ASP.NET Core MVC using Visual Studio on Windows --【在 windows上用VS创建mvc web app】
Create a web app with ASP.NET Core MVC using Visual Studio on Windows 在 windows上用VS创建mvc web app 201 ...
随机推荐
- OBS直播抠绿插件(Matting123)
一.产品概述 OBS直播抠绿插件(Matting123)是使用绿幕.蓝幕进行抠像的虚拟直播软件,本软件需要配合OBS30.0.0或以上版本进行使用.Matting123采用自研抠图算法,该算法已达到影 ...
- Managing Difficulties
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define FOR(i,n,m) for(int i=n;i<=m;i++) ...
- Linux离线安装Tomcat
系统环境: centos7.3.1611 openjdk version "1.8.0_102" apache-tomcat-9.0.36.tar.gz tomcat 安装 #链接 ...
- SQLserver 数据库自定义函数
起源 最近项目开发上使用的SQLserver数据库是2008版本,由于08版本的数据是没有字符串合并(STRING_AGG)这个函数(2017版本及以上支持)的,只有用stuff +for xml p ...
- Python批量分割Excel后逐行做差、合并文件的方法
本文介绍基于Python语言,针对一个文件夹下大量的Excel表格文件,基于其中每一个文件,首先依据某一列数据的特征截取我们需要的数据,随后对截取出来的数据逐行求差,并基于其他多个文件夹中同样大量 ...
- 通过DashScope API调用将多种模态转换为向量
本文介绍如何通过模型服务灵积DashScope进行 多模态向量生成 ,并入库至向量检索服务DashVector中进行向量检索. 模型服务灵积DashScope,通过灵活.易用的模型API服务,让各种模 ...
- 知乎问题:为什么很多web项目还是使用 px,而不是 rem?
阅读过几篇关于 px rem 的文章,感觉 rem 很强大.但是自己接触到的公司项目全部都使用 px,想知道为什么.是我司技术更新落后了吗? 我们当然有在用 vw 和 vh,但是只是在 layout ...
- Google Analytics & Ads 学习笔记 2 (gtag 版本)
gtag 是用来取代之前的 ga 的 但其实它底层就是调用 ga 而已. 只是封装了一个上层. 1. start up script <script async src="https: ...
- SQL Server – Schema
前言 久仰 dbo 大名, 但是一直没有认真去看它有啥作用. 今天翻看了一下 SQL Server sample database: AdventureWorks2019, 发现它用了许多 Schem ...
- ubuntu22.04安装DBeaver
要在 Ubuntu22.04 上安装 DBeaver,可以选择使用 Ubuntu 软件中心的图形界面方法或使用命令行方法通过官方 DBeaver 仓库或 Snap 包安装. 方法一:从官方仓库安装 D ...