# Agent inherit -Xmx flag from application

**URL:** <https://discuss.elastic.co/t/agent-inherit-xmx-flag-from-application/219732>\
**Category:** APM\
**Tags:** java\
**Created:** [February 18, 2020, 8:16am UTC](https://discuss.elastic.co/t/agent-inherit-xmx-flag-from-application/219732 "2020-02-18T08:16:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmacew](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@kmacew](https://discuss.elastic.co/u/kmacew)\
**Post date:** [February 18, 2020, 8:16am UTC](https://discuss.elastic.co/t/agent-inherit-xmx-flag-from-application/219732/1 "2020-02-18T08:16:53Z")

</div>

If you are asking about a problem you are experiencing, please use the following template, as it will help us help you. If you have a different problem, please delete all of this text 🙂

**Kibana version** : 7.5

**Elasticsearch version** : 7.5

**APM Server version** : 7.5

**APM Agent language and version** : 1.8 en

**Browser version** :

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: executable

**Fresh install or upgraded from other version?** Fresh install

**Is there anything special in your setup?** For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc.

No

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:

I use -javaagent flag to attach elastic-apm-agent to my java process with command:

start C:\ProgramData\Oracle\Java\javapath\java.exe -javaagent:C:\Tools\apm\elastic-apm-agent-1.8.0.jar -Delastic.apm.environment=xxx -Delastic.apm.service\_name=xxx -Delastic.apm.server\_url=xxx -Xmx512m -Delastic.apm.secret\_token=xxx -jar xxx.jar

the problem is elastic-apm-agent inherit -Xmx flag from the application, is there a way to set -Xmx different for elastic-apm-agent? E.g. -javaagent::-Xmx256m

**Steps to reproduce** :  
1.  
2.  
3.

**Errors in browser console (if relevant)**:

**Provide logs and/or server output (if relevant)**:

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [February 18, 2020, 8:44am UTC](https://discuss.elastic.co/t/agent-inherit-xmx-flag-from-application/219732/2 "2020-02-18T08:44:25Z")

</div>

Hi and thanks for your question.

The agent runs within the same JVM as your application, not in separate one, thus it shares the same heap configuration with your application.

---

<div class="post-metadata">

**Author:** ![kmacew](https://avatars.discourse-cdn.com/v4/letter/k/b77776/32.png) [@kmacew](https://discuss.elastic.co/u/kmacew)\
**Post date:** [February 18, 2020, 8:46am UTC](https://discuss.elastic.co/t/agent-inherit-xmx-flag-from-application/219732/3 "2020-02-18T08:46:15Z")

</div>

Hi,

Thanks for reply.

Regards,  
Krzysztof

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 10, 2020, 4:46am UTC](https://discuss.elastic.co/t/agent-inherit-xmx-flag-from-application/219732/4 "2020-03-10T04:46:22Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
