When deploying or redeploying one or many APIs, you run out of Java´s metaspace memory.
Every time you deploy an API, its metadata is loaded into a specific Java memory called Metaspace.
(The metaspace memory was introduced in Java 8. Before that, it was called Java´s PermGen memory)
There are two kinds of causes:
1) Your metaspace memory sizing configuration is just too small
2) At least one of your APIs has a metaspace leak and fills your metaspace memory every time you redeploy it
Cause # 1) To solve a wrong metaspace memory sizing, go to your $MULE_HOME/conf/wrapper.conf file and edit the following lines to adjust your needs:
wrapper.java.additional.7=-XX:MaxMetaspaceSize=256m wrapper.java.additional.8=-XX:MetaspaceSize=128m
(These are the default values for Mule 4.3.0 runtime but you should change them based on your sizing. If you need help with sizing, please contact your Customer Success Manager)
Ensure that the MetaspaceSize is always lower than the MaxMetaspaceSize. For more explanation on the reason, refer to https://help.salesforce.com/articleView?id=001118204&type=1&mode=1&language=en_US.
Cause # 2) Even though the metaspace memory is not readable, we can infer it by reading a heap dump. So there are two alternatives here:
2.A) To wait until it fails:
To do this, just configure your runtime to take an automatic heap dump upon an out-of-memory event, so even though it will fail, it will also create a file with the "hprof" extension that MuleSoft Support can help you analyze to locate the leaking APIs.
More info: How to gather heap dump on JVM out of memory error
2.B) To force the failure:
More info: How to Obtain as Much Information as Possible from an Unresponsive Mule Server
Important: We recommend redeploying at least three times since with fewer redeployments we can confuse regular class loading and garbage collection with leaks. So please, redeploy at least three times each API
TIP: It´s not necessary to redeploy using Runtime Manager since we know it could be time-consuming. Our recommendation is to go into the API folder at $MULE_HOME/apps/<api_name> and add an empty XML file or perform a small modification like changing a logger text. That will force the redeployment and it will be faster than using the Runtime Manager method.
An alternative to address a metaspace leak is to monitor your Java instance and restart the runtime before reaching the maximum metaspace size. This is not fixing the issue but you may avoid several outages until you get the root cause and solve it.
More info: How to monitor JVM native memory usage by enabling native memory tracking
001121470

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.