Hi this makes the situation *much* better. Thank you!
I just read the discussion of the issue you linked to. I wonder why not to use this property of groovy.use.classvalue=true as the default setting? At least in my case it seems that the created dynamic classes are collected as well. Tino Am 27.06.2016 um 20:25 schrieb jwagenleitner [via Groovy]: > Adding the following system property may help to extend the time > before OOM: > > groovy.use.classvalue=true > > At least for me on Groovy 2.4.7 with jdk8_91 using that property let > the loop run 25 minutes (made about half the iterations) vs. ~2.5 > minutes without the property. I used a 64m heap. > > I believe the problem is related to GROOVY-7683. > > On Fri, Jun 24, 2016 at 11:12 PM, t.schoellhorn <[hidden email] > </user/SendEmail.jtp?type=node&node=5733552&i=0>> wrote: > > Hi, we are using Groovy in our web-application. There we create a > "lot" of dynamic String and are handling that with the > TemplateEngine as we need more complex expressions there. Now we > noticed that we are running into a kind of weird OOM situation. I > could narrow the problem down to a quite simple reproducible example: > > package kos.tools.template; > > import java.util.HashMap; > import java.util.Map; > > import javax.script.Bindings; > import javax.script.ScriptEngine; > import javax.script.ScriptEngineManager; > import javax.script.SimpleBindings; > > public class Test { > > > public static void main(String[] args) throws Exception { > ScriptEngineManager factory = new ScriptEngineManager(); > ScriptEngine engine = factory.getEngineByName("groovy"); > > String template = "step-${i}"; > > String groovy = > "def engine = new > groovy.text.GStringTemplateEngine();\n" + > "def res = > engine.createTemplate(template).make(bindings);\n" + > "return res.toString();"; > > for (int i = 0; i < (10000000); i++) { > Bindings vars = new SimpleBindings(); > vars.put("template", template); > > Map<String, Object> templateObjects = new HashMap<>(); > vars.put("bindings", templateObjects); > templateObjects.put("i", i); > > Object res = engine.eval(groovy, vars); > > if (i % 100 == 0) { > System.out.println("->" + res); > } > } > } > > } > > Running that example with an Oracle JDK 1.8 and a quite small > memory (just for keeping the running time small) of 32M leads to > an OOM at around 2500 steps. I opened up a disussion on > Stackoverflow where John Vint gave me some hints (see here > > <http://stackoverflow.com/questions/37992822/groovy-templateengines-and-outofmemory-possible-memory-leak?>) > and it might be also a bug of the GarbageCollector itself. But in > essence I think there should be a way to use the TemplateEngine in > a stable way. I am happy for any suggestions and examples of how > to solve this situation. Tino > ------------------------------------------------------------------------ > View this message in context: TemplateEngines and Out of Memory > > <http://groovy.329449.n5.nabble.com/TemplateEngines-and-Out-of-Memory-tp5733514.html> > Sent from the Groovy Users mailing list archive > <http://groovy.329449.n5.nabble.com/Groovy-Users-f329450.html> at > Nabble.com. > > > > > ------------------------------------------------------------------------ > If you reply to this email, your message will be added to the > discussion below: > http://groovy.329449.n5.nabble.com/TemplateEngines-and-Out-of-Memory-tp5733514p5733552.html > > > To unsubscribe from TemplateEngines and Out of Memory, click here > <http://groovy.329449.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5733514&code=dC5zY2hvZWxsaG9ybkBwbGF0dGZvcm0tZ21iaC5kZXw1NzMzNTE0fDExNTI1OTE5NzQ=>. > NAML > <http://groovy.329449.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > > -- Tino Schöllhorn Diplom Wirtschaftsinformatiker Geschäftsführer Plattform GmbH Gabelsbergerstr. 5 68165 Mannheim Tel: 0621-58679312 E-Mail: t.schoellh...@plattform-gmbh.de Internet: http://www.plattform-gmbh.de Registergericht: Amtsgericht Mannheim, HRB 9955 Geschäftsführer: Olaf Kellermeier, Tino Schöllhorn -- View this message in context: http://groovy.329449.n5.nabble.com/TemplateEngines-and-Out-of-Memory-tp5733514p5733568.html Sent from the Groovy Users mailing list archive at Nabble.com.