RankFilter is making my ImageJ plugin freeze

I am writing an ImageJ plugin in Java, and I have a problem using the Maximum… Filter.
Well, it does not extend PlugIn, it is just a Java script…
Basically, I loop through images in a folder, but randomly, the script freezes right after calling the Maximum Filter.

I have tried both:

IJ.run(imp, "Maximum...", "radius=3");


new RankFilters().rank(imp.getProcessor(), 3, RankFilters.MAX);

but I still get the freeze. And not exception to be caught…

Any idea?