Live data from Hacker News

Detecting a permgen memory leak in a Java application

smalldata.tech

11–15 of 15 posts

Re: Detecting a permgen memory leak in a Java application

#11
post #2

> Steps to use visualvm to profile memory for a standalone JBoss application: > Allow visualvm to use 1024 Mb of RAM - in etc/visualvm.conf update -Xmx parameter to -J-Xmx1024m And this is why I avoid all Java apps I can -- there is always a need for some memory tuning. C++, Lisp, Perl, Go, Python, even Javascript can all use all the memory in my computer have without any action on my part, only Java keeps having the…

The default limit is usually 25% of total physical memory. Should the default limit be the maximum? I think it's fine to have the default limit where it's at, to force me to think about what the actual requirements are. When you mean "tuning", do you also mean random GC tweaks? Those are generally best avoided these days, in my opinion. The auto tuning works well enough, and manual settings tend to cause more harm than good in the long run.

Re: Detecting a permgen memory leak in a Java application

#12
post #2

> Steps to use visualvm to profile memory for a standalone JBoss application: > Allow visualvm to use 1024 Mb of RAM - in etc/visualvm.conf update -Xmx parameter to -J-Xmx1024m And this is why I avoid all Java apps I can -- there is always a need for some memory tuning. C++, Lisp, Perl, Go, Python, even Javascript can all use all the memory in my computer have without any action on my part, only Java keeps having the…

No they can't. You're just to inexperienced to know this.

Re: Detecting a permgen memory leak in a Java application

#13
post #2

> Steps to use visualvm to profile memory for a standalone JBoss application: > Allow visualvm to use 1024 Mb of RAM - in etc/visualvm.conf update -Xmx parameter to -J-Xmx1024m And this is why I avoid all Java apps I can -- there is always a need for some memory tuning. C++, Lisp, Perl, Go, Python, even Javascript can all use all the memory in my computer have without any action on my part, only Java keeps having the…

I wonder why I had to do memory tuning on C applications back in 2000.

By the way, when using Java 16, not Java 7 like in the article, those parameters aren't needed.

Re: Detecting a permgen memory leak in a Java application

#14
post #2

> Steps to use visualvm to profile memory for a standalone JBoss application: > Allow visualvm to use 1024 Mb of RAM - in etc/visualvm.conf update -Xmx parameter to -J-Xmx1024m And this is why I avoid all Java apps I can -- there is always a need for some memory tuning. C++, Lisp, Perl, Go, Python, even Javascript can all use all the memory in my computer have without any action on my part, only Java keeps having the…

The default limit is usually 25% of total physical memory. Should the default limit be the maximum? I think it's fine to have the default limit where it's at, to force me to think about what the actual requirements are. When you mean "tuning", do you also mean random GC tweaks? Those are generally best avoided these days, in my opinion. The auto tuning works well enough, and manual settings tend to cause more harm th…

The problem is: when devs have learned about a necessary tuning knob, it's almost impossible to get them to stop touching it.

So recent JDKs have a sane default. Finally. Now we have a zillion app from the time defaults were not sane, each having a few -Xm parameters in their config. If they work well enough, nobody takes the effort to remove them. If they don't work, just type a higher number and test.

Manual JVM memory tuning will stay with us forever.

Re: Detecting a permgen memory leak in a Java application

#15
post #10

Detecting? It's safe to assume that if there's any statics there's a permgen leak.

Mutable collection type static field members that are actually mutated, sure. Thread creation in a static initializer? Yeah, that’s going to be a leak- but what you said was: > It’s safe to assume that if there’s any statics there’s a permgen leak. private static final int INT_PHI = 0x9e3779b9; // this is a useful constant that can be inlined in JIT code output, and not a memory leak.

It might use the word static, but in my head it's just a const, obviously fixed integers don't leak. Why bother pointing this out?
Post reply on HN