【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 ...
随机推荐
- XSS 基本概念和原理介绍
XSS 基本概念和原理介绍 基本概念 跨站脚本攻击 XSS(Cross Site Scripting),为了不和层叠样式表 ( Cascading Style Sheets,CSS ) 的缩写混淆,故 ...
- 代码随想录Day21
669. 修剪二叉搜索树 给你二叉搜索树的根节点 root ,同时给定最小边界low 和最大边界 high.通过修剪二叉搜索树,使得所有节点的值在[low, high]中.修剪树 不应该 改变保留在树 ...
- poi的excel导出
poi的excel导出 这个导出依赖于模板文件,可便捷设置表头样式. 也可以不使用模板,直接创建. 1.引入poi依赖 <dependency> <groupId>org.ap ...
- 这才是java对象正解
这才是 Java 对象正解 在深入讨论对象之前,让我们先明确对对象和实例的理解. 什么是对象? 对象(Object)是内存中分配的实际数据结构,它包含了数据和方法.在 Java 中,对象是类的一个实例 ...
- 2022 CCPC 广州站 Alice and Her Lost Cat
1 #include <bits/stdc++.h> 2 using namespace std; 3 #define rg register 4 #define ll long long ...
- bacnet mstp设备数据 转IEC61850项目案例
目录 1 案例说明 1 2 VFBOX网关工作原理 1 3 使用YABE软件读取BACNET MSTP设备信息 2 4 配置网关采集BACNET MSTP数据 4 5 用IEC61850协议转发数据 ...
- Azure – DNS
前言 以往 DNS 都是用 Domain 公司免费提供的. 但这类 DNS 一般都不支持 API 访问. 这就会导致无法自动 renew Let's Encrypt wildcard SSL. 所以用 ...
- Azure 入门系列 (第三篇 Publish Web Application to VM)
本系列 这个系列会介绍从 0 到 1 搭建一个 Web Application 的 Server. 间中还会带上一些真实开发常用的功能. 一共 6 篇 1. Virtual Machine (VM) ...
- SQL Server – Trigger 触发器
参考: SQLServer触发器详解(概述.工作原理.应用) CREATE TRIGGER (Transact-SQL) SQL Server Triggers and Transactions 以前 ...
- Nacos 开启鉴权设置
Nacos 开启鉴权设置 # 开启鉴权 nacos.core.auth.enabled=true nacos.core.auth.system.type=nacos # 开启鉴权之后,你可以自定义用于 ...