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

Deleted user October 21, 2012

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

0 votes
Answer accepted
Deleted user November 5, 2012

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

0 votes
Radu Dumitriu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 21, 2012

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 ...

Deleted user October 22, 2012

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

0 votes
Deleted user October 21, 2012

Thanks a lot, I will try it.

0 votes
Norman Abramovitz
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 21, 2012

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

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

0 votes
Norman Abramovitz
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 21, 2012

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.

0 votes
Deleted user October 21, 2012

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

0 votes
Norman Abramovitz
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 21, 2012

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?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events