How to limit heap size in a JVM 8?

Asked

Viewed 919 times

1

Until jvm 7 the -Xmx parameter limited the heap size, but today in jvm 8 this is not happening.

Today I use the -Xmx200m parameter and my application even consumes 1.5GB in heap, I use a lot of short duration object so practically they stay in Eden.

I’ve tried several parameters but none with success. The issue that my server is knocking down some applications for lack of memory and I would like to limit the size of their heap.

1 answer

1


According to the documentation, you can do this using the parameter -XX:MaxHeapSize.

  • I guess you didn’t read the question right. And the metaspace link went to a question of mine that relates to this one. I say that I use short-lived objects and that they all stay in Eden and barely pass to Survivor 0 and 1. I would like to know if there is any way to limit the size of the heap because I have physical limitation of RAM on the machine I use. http://middlewaremagic.com/weblogic/wp-content/uploads/2010/11/Java_Heap_Diagram_12.jpg do you agree that we are talking about different things? I’m talking.

  • I understood your question. I even pointed out that Java 8 no longer deals with this kind of thing. If your application is eating too much memory then you need to use less memory or buy a better server. Limit the heap size will only cause errors in your application.

  • is to cause error yes but not to take down other more important applications. Well, from what you tell me the -Xmx parameter is no longer valid, but why is it in the documentation yet? Java 8 is the great memory consumer and what we can do is buy another machine? Is there no way to limit the size of the memory used by it and point to the development team? That’s it?

  • If you wanted the mistake to happen, you should make it clear in your question. What consumes memory is not java is your application Anyway, I edited my answer..

Browser other questions tagged

You are not signed in. Login or sign up in order to post.