how to deal with Jira jsonobject's out of memory exception?

Hi all,

I am writing a plugin archiving jira issue to another service.

The transfer format of issue is json.

When I test on a collection of issues with the total number of issues is about 41000+, it always throw Out of memory exception after certain number of issues transfered.

The out of memory exception is throwed on line:

com.atlassian.jira.util.json.JSONObject.toString(JSONObject.java:1260)

Any people encounter this? Using atlassian.jira.util.JSONObject getting out of memory exception?

Please help suggest and share thoughs here.

Thanks & Regards,

Yaoyu

7 answers

1 accepted

Accepted Answer
0 votes

Finally found there is one issue with very very huge svn commit messages. If use json even handle only this issue will trigger the out of memory exception.

Regards,

Yaoyu

A few thoughts

How much memory is allocated for Jira?

How big does your json object get? Are you trying to send multiple issues in a single json request?

Can you use one of Java's memory leak detection tools?

Hi Norman,

Thanks. Please see my answer below.

How much memory is allocated for Jira?

>>2G.

How big does your json object get?

>> combine jira rest json and svn plugin json string.

Are you trying to send multiple issues in a single json request?

>> no, one issue one json then send and handle another issue.

Can you use one of Java's memory leak detection tools?

>> could you please help recommend any one?

And,

I am thinking maybe every time I process issue I will new a com.atlassian.jira.util.JSONObject cause this.

I try to reuse the JsonObject. but I failed to find mehtod on this object to reuse it.

Do you think set the reference as null will help?

Or another thought from mine is after processing every 1000 issues I put thread sleep for couple of seconds, will this help?

Thanks & Regards,

Yaoyu

It is hard to say which coding changes will work or not, but using a memory leak dectector will point you in the right direction.

I have used MAT before, but anyone that works with your development environment will do.

http://www.eclipse.org/mat/

Thanks a lot, I will try it.

Page your response. That OOM can be thrown if a string is too large (which I suspect is the case). Serialization in JSON does not write directly to the stream (and since you need to keep it until you write it, you need memory), you either need to serialize pages of data or use json streaming.

Plus, there are some gotchas in the Jackson implementation ...

Hi, So do you know how to reuse the com.atlassian.util.JSONObject? I think for each issue, I will new some this class instances. Then it will consume the memory.

And I use HTTPURLConnection object to transfer the json.

I find I forget disconnect every time after I transfer the json.

Will this HTTPURLConnection object consume the memory?

Thanks,

Yaoyu

Suggest an answer

Log in or Sign up to answer
Community showcase
Published yesterday in Jira Ops

Jira Ops Early Access Program Update #1: Announcing our next feature and a new integration

Thanks for signing up for Jira Ops! I’m Matt Ryall, leader for the Jira Ops product team at Atlassian. Since this is a brand new product, we’ll be delivering improvements quickly and sharing updates...

195 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you