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

This widget could not be displayed.

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

This widget could not be displayed.

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?

This widget could not be displayed.

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

This widget could not be displayed.

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.

This widget could not be displayed.

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

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

This widget could not be displayed.

Thanks a lot, I will try it.

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

194 views 18 7
Join discussion

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