Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Memory Out of Control  RSS feed

 
Nitin Dubey
Ranch Hand
Posts: 126
Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a java application that keeps running for months together. Past updates to the application with new third party api's have caused the application to go out of memory after 10-15 days of processing. It is obvious that there are memory leaks. I did PMD and then profiling for the application and found that most of the memory leaks are coming out of third party libraries.

In order to solve the problem I can ask the vendors for fixes but that takes long duration.

Is there any method in java world to keep such things in control? I can think of something like transaction savepoints, where we take a snapshot of java mem and then rollback to the same state after say 10 days or something. This cannot be done through java api since it has no direct control over the memory. It is also evident that most of the people get into such kind of problems, how do they overcome it?

Your suggestions are required.

Cheers,


Nitin
 
Kees Jan Koster
JavaMonitor Support
Rancher
Posts: 251
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Nitin,

I have never heard of making save points and then restarting the JVM underneath. If you want this, you app should have been coded to support it.

I'm not sure how rolling back the JVM to a previous state is different from just restarting it. I mean, sessions that were valid in the 10-days-ago state are invalid, as are database connections etc.

In your shoes I would just try to give the JVM more memory and schedule restarts at relatively quiet hours.

One thing though: in some cases the memory leak is not *in* the 3rd party library, but in the way your application code uses that library. So perhaps it is a good idea to have the developers review the application code to establish that the 3rd-party library is actually used correctly. I can make any library appear to leak if I just create instances of its classes and keep them in a hash map. :-)
 
Joe Ess
Bartender
Posts: 9425
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you contacted your third party vendor's support? It sounds like they may have made some changes to their API.
I had some problems with Weblogic API's when upgrading and I ended up creating a dummy application which did nothing but exercise the portion of the API which was giving me problems. This proved that the problem was not in my code and gave their support and me a common frame of reference to use when working on a solution. Can you prove the problem is in the third-party code?
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got nailed by this several years back. In my case, it was because I was using JDO and it was employing an Oracle component whose "cache" didn't meet my definition of the term. Specifically, it didn't age out - once something went in, it was in forever and so the "cache" grew and grew and gre until it brought down the app.

Misnomer, notwithstanding, that's actually how Oracle intended it to behave, and it was documented as such - IF you knew where to look. It wasn't exactly front-page knowledge. In my case, I resolved the problem by adjusting some options to pull in an alternate caching solution.

Sometimes there is no alternative. In cases like this, you're pretty much stuck restarting the JVM. You can reduce the impact by doing a scheduled (off-hours) restart before the critical threshold is breached. If the app is too critical for that, you probably should have it run clustered. Then you should be able to cycle the components of the cluster and still maintain uptime.

That's just a workaround while you nag the vendors to fix their code - although it's a good strategy for critical services in general. If the problem is in open-source code, and you're annoyed enough, you can also fix it yourself. But if you do, please send the fix to the authors so that they can look at integrating it into a future release.
 
Nitin Dubey
Ranch Hand
Posts: 126
Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably it is for a good reason. Had there existed a tool then it might have resulted into some bad code.

The problem was identified and fixed. We got a patch from the vendor.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!