1

My product has 256 MB of RAM. I have upgrade java 6 to java 8. Then I started facing memory related issue with java 8. memory consumption is incresing by the time with Java 8 With same code, memory consumption is stable with java 6 I have explored so much regarding metaspace,java8 and found below metaspace parameters.

I have tried below combinations and got out of memory error

1.MaxMetaspaceSize 50M MaxMetaspaceFreeRatio 60M MinMetaspaceFreeRatio 50M

2.MaxMetaspaceSize 30M

3.MaxMetaspaceSize 40M

4.MaxMetaspaceSize 50M

5.MaxMetaspaceSize 80M

But after 2 to 3 hours ,outofmemory metaspace error raised.

Can someone explain what the metaspace options MaxMetaspaceSize,MaxMetaspaceFreeRatio ,MinMetaspaceFreeRatio are?

How do I decide what the right size is? what is the correct combination of these values to avoid outofmemory instance in production and reduce memory consumption ?

Smash
  • 63
  • 3
  • 9
  • 1
    I don’t understand, why developers keep messing around with these options. The default is *unlimited* metaspace. So if you don’t know which limitations are the best, don’t specify any limitations. – Holger Sep 02 '16 at 08:21
  • If we don't specify the limit , it can end up with huge native memory allocation. – Smash Sep 02 '16 at 09:26
  • 1
    Yeah, and if you specify a limit, it can end up with an `OutOfMemoryError`. The choice is yours… – Holger Sep 02 '16 at 09:28
  • If i don't set any metaspace attribute, Metaspace keeps on increasing even GC is not cleaning/unloading classes from metaspace. why this is happening ? what should i do to clean metaspace when GC is run? – Smash Sep 04 '16 at 06:58
  • You don’t. If a software has a memory leak, no JVM option will fix that. You have to fix the software. – Holger Sep 05 '16 at 09:33
  • If the same software has memory leak than why it is working fine with Java 6? The code is scanned and it has no leak – Smash Sep 05 '16 at 18:27

1 Answers1

2

The issue is resolved. Found that there are known issue with JAXB.

  • Used stringbuffer instead of string
  • Removed unnecessary instance of JAXBContext.
  • Refer this link

  • Are there any memory utlization issue with JAXB?
  • Community
    • 1
    • 1
    Smash
    • 63
    • 3
    • 9