Groovy Scripts use to many memory (out of memory) and don't release it (Bob Swift Scripting)

We use many groovy scripts in confluence. We updated to the new confluence version (from 2.10 to 5.9.8). After this update the old loading mechanic to load the sql connection in groovy script doesn't work. So we decided to use the class loader (See https://bobswift.atlassian.net/browse/SCRP-148)

But now we must restart the system two times a day. Because out of memory:

image.png

 

We tested many calls to a normal confluence page. Very less memory usage. The same when we use a simple groovy script without loading classes with the class loader. Only when we use the class loader it is an problem.

*What can we do to release the memory of groovy scripts?*

I tried this: https://bobswift.atlassian.net/browse/SCRP-134. But no improvement.

Here my code to load the oracle connection it:

URL[] jarFiles = new URL[1];
jarFiles[0] = new URL("jar:file:/opt/atlassian/confluence/lib/ojdbc6.jar!/");
//The following two lines needs many memory and don't release it (close or finalise doesn't helps)
def classLoader = URLClassLoader.newInstance(jarFiles, ClassLoader.getSystemClassLoader());
Driver driver = (Driver) Class.forName('oracle.jdbc.driver.OracleDriver', true, classLoader).newInstance()
def properties = new Properties()
properties.setProperty('user', userName)
properties.setProperty('password', password)
def connection = driver.connect(connectString, properties)
def result = Sql.newInstance(connection);
driver.finalize()
classLoader.finalize()
return result


Thank you!

1 answer

This is covered by SCRP-206.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

910 views 23 12
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