Creating new JLanguageTool object Performance

Does JLanguageTool class loads dictionary/grammar rules or any other config from file every time when objects are created?

Like

JLanguageTool tool = new JLanguageTool(new AmericanEnglish());

Or it reads once when class is initialized for first time? I am interested in the performance impact of initializing new object due to file operation or any other heavy lifting?

For best performance, the recommended approach is to create a new JLanguageTool, but to create the language only once (e.g. new English()) and use that for all JLanguageTool instances. In other words, creating the language takes performance, not the JLanguageTool object.

We have only recently introduced better thread-safety though so for a production system you might still want to create a new language as there might still be bugs lurking in the approach described above.

Thanks for the response.

Is it safe to reuse English() object by passing to multiple JLanguageTool() objects?

It should be safe now, but we had some bugs in the recent past. I suggest you use the current snapshot versions.

I have created the new English() language only once, When i tried with multiple request, it results in a Run Time Error(BufferUnderflowException) and all my other requests gets failed. Any work around for this?

BTW just to check performance, i have increased my Heap memory space to 10G and tried,

The error rate increases a lot.

So you have one JLanguageTool per request? Please post the complete stack trace then.