WebView.SetMemoryUsageTargetLevel
---------------------------------

Sets MemoryUsageTargetLevel to indicate desired memory consumption level of WebView.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [WebView](component_WebView.md) | [15.4](newinversion154.md) | ❌ No | ✅ Yes | ❌ No | ❌ No | ❌ No |

MBS( "WebView.SetMemoryUsageTargetLevel"; WebViewerRef; Value ) 

**MBS**( **"WebView.SetMemoryUsageTargetLevel";** /\* Sets MemoryUsageTargetLevel to indicate desired memory consumption level of WebView. \*/  
**$WebViewerRef**; /\* Either the Web Viewer Object Name or the Web Viewer ID as returned by "[WebView.FindByName](WebViewFindByName.md)" function.e.g. $webView2 \*/   
**$Value**) /\* The new setting.  
Pass 0 for normal and 1 for low.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| WebViewerRef | Either the Web Viewer Object Name or the Web Viewer ID as returned by "[WebView.FindByName](WebViewFindByName.md)" function. | $webView2 |
| Value | The new setting.   Pass 0 for normal and 1 for low. | 0 |

### Result

Returns OK or error.

### Description

Sets MemoryUsageTargetLevel to indicate desired memory consumption level of WebView.  
Value is 0 for normal and 1 for low.  
  
Scripts will not be impacted and continue to run. This is useful for inactive apps that still want to run scripts and/or keep network connections alive and therefore could not call TrySuspend and Resume to reduce memory consumption. These apps can set memory usage target level to kMemoryUsageTargetLevelLow when the app becomes inactive, and set back to kMemoryUsageTargetLevelNormal when the app becomes active.   
  
It is not necessary to set CoreWebView2Controller's IsVisible property to false when setting the property. It is a best effort operation to change memory usage level, and the API will return before the operation completes. Setting the level to kMemoryUsageTargetLevelLow could potentially cause memory for some WebView browser processes to be swapped out to disk in some circumstances. It is a best effort to reduce memory usage as much as possible. If a script runs after its related memory has been swapped out, the memory will be swapped back in to ensure the script can still run, but performance might be impacted. Therefore, the app should set the level back to kMemoryUsageTargetLevelNormal when the app becomes active again. Setting memory usage target level back to normal will not happen automatically.   
  
An app should choose to use either the combination of TrySuspend and Resume or the combination of setting MemoryUsageTargetLevel to low and normal. It is not advisable to mix them. Trying to set MemoryUsageTargetLevel while suspended will be ignored. The TrySuspend and Resume methods will change the MemoryUsageTargetLevel. TrySuspend will automatically set MemoryUsageTargetLevel to low while Resume on suspended WebView will automatically set MemoryUsageTargetLevel to normal. Calling Resume when the WebView is not suspended would not change MemoryUsageTargetLevel.  
### See also

- [WebView.FindByName](WebViewFindByName.md)
- [WebView.GetMemoryUsageTargetLevel](WebViewGetMemoryUsageTargetLevel.md)

### Release notes

- **Version 15.4**
    - Added [WebView.GetMemoryUsageTargetLevel](https://www.mbsplugins.eu/WebViewGetMemoryUsageTargetLevel.shtml) and [WebView.SetMemoryUsageTargetLevel](https://www.mbsplugins.eu/WebViewSetMemoryUsageTargetLevel.shtml) for Windows.

### Blog Entries

- [MBS FileMaker Plugin 15.4 News](https://www.mbsplugins.de/archive/2025-09-23/MBS_FileMaker_Plugin_154_News/monkeybreadsoftware_blog_filemaker)
- [Neues MBS Plugin 15.4 für Claris FileMaker](https://www.mbsplugins.de/archive/2025-09-09/Neues_MBS_Plugin_154_für_Clar/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin 15.4 for Claris FileMaker](https://www.mbsplugins.de/archive/2025-09-09/MBS_Plugin_154_for_Claris_File/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 15.4pr1](https://www.mbsplugins.de/archive/2025-08-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 21st July 2025 , last changed 21st July 2025

  
[WebView.SetMediaVolume](WebViewSetMediaVolume.md) - [WebView.SetPageSizeMultiplier](WebViewSetPageSizeMultiplier.md)

[HTML Version](WebViewSetMemoryUsageTargetLevel.shtml)