curlyreggie
curlyreggie

Reputation: 1530

Jade: java.lang.OutOfMemoryError: Java Heap Space

I've been using jade (Java Agent Development Framework) for creating a network based messaging system.

So far, I notice that jade was running without issues but one fine day, I get this message,

enter image description here

A JVM Heap Space error!

After investigating, I find out that this is due to the collection variable that might be clogging up objects which is occupying the JVM space without flushing it out. (you can see that Exception is raised from the jade perspective and nothing from my code side)

How can I remove this?

My code consists of a simple TickerBehaviour class as below:

public class MyBehaviour extends TickerBehaviour {

 @Override
 public void onTick() {
   // Runs every second.

   ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
   msg.setOntology(username);
   msg.addReceiver(new AID(username, AID.ISLOCALNAME));
   msg.setContent(<my intended message to that identifier>);
   agent.send(msg);
 }
}

I further checked if my code is creating unnecessary referenced objects (by commenting the code which finally generates my intended message as a way) I bring it down to removing all my functionality and just run the jade agent, and surprisingly, I notice that jade task itself is creating this issue.

I used visualVM to inspect the ongoing Heap Space inspection for live object creation to check how many referenced objects are still being located in JVM Heap space.

Older solutions aren't helping much either. Can anyone help me tackle this issue?

I have used the options recommended during the start of the jade Container but there are referenced objects still present which aren't being removed by GC.

System Setup:

  1. OS: Linux 64-bit.
  2. JVM Version: IcedTea, 1.6.0.27 , 64-bit.
  3. JVM Options: -Xms1024m, -Xmx2048m and -XX:MaxPermSize=512M

Thank you in advance.

Upvotes: 3

Views: 1224

Answers (3)

curlyreggie
curlyreggie

Reputation: 1530

The problem was with another engine that was buffering objects for processing. JADE wasn't the culprit. I was using a common ESPER Engine and creating new objects for event processing from the data being parsed.

I'm investigating how to flush out those contents periodically without crashing the application.

Sorry for the trouble!

Upvotes: 0

Nikem
Nikem

Reputation: 5784

One of the simplest things I can recommend is to use Plumbr. It is meant exactly for such cases. If Plumbr reports that the problem lies in Jade code, then you should submit a bug report to them. Or it will help you spot the problem in you own application.

Upvotes: 1

Stephen C
Stephen C

Reputation: 718826

How can I remove this?

You seem to have investigated this as a memory leak, and concluded that the leak is in Jade.

If that is the case, then the first thing to do is to trawl the Jade mailing lists and bug tracker to see if this is a known problem, and if there is a known fix or workaround.

If that fails, you've got three choices:

  • Investigate further and track down the cause of the memory leak, and develop a fix for it. If the fix is general, contribute it back to the Jade team.

  • Report the bug on the Jade bug tracker and hope that this results in a fix ... eventually.

  • Bandaid. Run your application with a larger heap, and restart it whenever you get an OOME.


The other possibility is that the memory leak is in, or is caused by your code. For instance, you say:

After investigating, I find out that this is due to the collection variable that might be clogging up objects which is occupying the JVM space without flushing it out. (you can see that Exception is raised from the jade perspective and nothing from my code side)

This is not watertight evidence that the problem is in Jade code. All it means is that you were executing a Jade method when the memory finally ran out. I'd advise you to download the Jade source code and investigate this (supposed) memory leak further. Figure out exactly what really causes it rather than basing your diagnosis on assumptions and faulty inferences.

Bear in mind that Jade is a stable product that many people are using successfully ... without memory leak issues.

Upvotes: 1

Related Questions